stat_power 0.1.0.alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +36 -0
- data/LICENSE +21 -0
- data/README.md +153 -0
- data/RELEASING.md +105 -0
- data/ROADMAP.md +99 -0
- data/docs/mathematical_conventions.md +88 -0
- data/docs/pwr_parity.md +62 -0
- data/lib/stat_power/correlation.rb +247 -0
- data/lib/stat_power/distributions/f_distribution.rb +141 -0
- data/lib/stat_power/distributions/noncentral_f.rb +217 -0
- data/lib/stat_power/distributions/noncentral_t.rb +103 -0
- data/lib/stat_power/distributions/normal.rb +130 -0
- data/lib/stat_power/distributions/student_t.rb +124 -0
- data/lib/stat_power/effect_size/conventional.rb +38 -0
- data/lib/stat_power/effect_size/proportion.rb +36 -0
- data/lib/stat_power/errors.rb +12 -0
- data/lib/stat_power/integration/adaptive_simpson.rb +133 -0
- data/lib/stat_power/normal_mean.rb +206 -0
- data/lib/stat_power/power_result.rb +20 -0
- data/lib/stat_power/proportion.rb +460 -0
- data/lib/stat_power/result.rb +6 -0
- data/lib/stat_power/solvers/bisection.rb +121 -0
- data/lib/stat_power/special_functions/beta.rb +100 -0
- data/lib/stat_power/t_test.rb +349 -0
- data/lib/stat_power/t_test_unequal.rb +247 -0
- data/lib/stat_power/unequal_power_result.rb +42 -0
- data/lib/stat_power/version.rb +5 -0
- data/lib/stat_power.rb +25 -0
- data/sig/stat_power.rbs +264 -0
- metadata +76 -0
data/sig/stat_power.rbs
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
module StatPower
|
|
2
|
+
VERSION: String
|
|
3
|
+
|
|
4
|
+
class Error < StandardError
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
class DomainError < Error
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class ConvergenceError < Error
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class Result
|
|
14
|
+
attr_reader sample_size: Integer?
|
|
15
|
+
attr_reader power: Float?
|
|
16
|
+
attr_reader effect_size: Float?
|
|
17
|
+
attr_reader alpha: Float?
|
|
18
|
+
|
|
19
|
+
def initialize: (
|
|
20
|
+
sample_size: Integer?,
|
|
21
|
+
power: Float?,
|
|
22
|
+
effect_size: Float?,
|
|
23
|
+
alpha: Float?
|
|
24
|
+
) -> void
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
class PowerResult
|
|
28
|
+
attr_reader sample_size: Float
|
|
29
|
+
attr_reader power: Float
|
|
30
|
+
attr_reader effect_size: Float
|
|
31
|
+
attr_reader alpha: Float
|
|
32
|
+
attr_reader alternative: Symbol
|
|
33
|
+
attr_reader analysis_method: String
|
|
34
|
+
|
|
35
|
+
def initialize: (
|
|
36
|
+
sample_size: Float,
|
|
37
|
+
power: Float,
|
|
38
|
+
effect_size: Float,
|
|
39
|
+
alpha: Float,
|
|
40
|
+
alternative: Symbol,
|
|
41
|
+
analysis_method: String
|
|
42
|
+
) -> void
|
|
43
|
+
|
|
44
|
+
def required_sample_size: () -> Integer
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
class UnequalPowerResult
|
|
48
|
+
attr_reader sample_size1: Float
|
|
49
|
+
attr_reader sample_size2: Float
|
|
50
|
+
attr_reader power: Float
|
|
51
|
+
attr_reader effect_size: Float
|
|
52
|
+
attr_reader alpha: Float
|
|
53
|
+
attr_reader alternative: Symbol
|
|
54
|
+
attr_reader analysis_method: String
|
|
55
|
+
|
|
56
|
+
def initialize: (
|
|
57
|
+
sample_size1: Float,
|
|
58
|
+
sample_size2: Float,
|
|
59
|
+
power: Float,
|
|
60
|
+
effect_size: Float,
|
|
61
|
+
alpha: Float,
|
|
62
|
+
alternative: Symbol,
|
|
63
|
+
analysis_method: String
|
|
64
|
+
) -> void
|
|
65
|
+
|
|
66
|
+
def required_sample_size1: () -> Integer
|
|
67
|
+
def required_sample_size2: () -> Integer
|
|
68
|
+
def total_sample_size: () -> Float
|
|
69
|
+
def required_total_sample_size: () -> Integer
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
module EffectSize
|
|
73
|
+
module Conventional
|
|
74
|
+
def self.resolve: (test: Symbol | String, size: Symbol | String) -> Float
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
module Proportion
|
|
78
|
+
def self.cohen_h: (p1: Numeric, p2: Numeric) -> Float
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
module NormalMean
|
|
83
|
+
def self.solve: (
|
|
84
|
+
?effect_size: Numeric | Symbol | String | nil,
|
|
85
|
+
?sample_size: Numeric | nil,
|
|
86
|
+
?alpha: Numeric | nil,
|
|
87
|
+
?power: Numeric | nil,
|
|
88
|
+
?alternative: Symbol | String
|
|
89
|
+
) -> PowerResult
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
module Proportion
|
|
93
|
+
def self.one_sample: (
|
|
94
|
+
?effect_size: Numeric | Symbol | String | nil,
|
|
95
|
+
?sample_size: Numeric | nil,
|
|
96
|
+
?alpha: Numeric | nil,
|
|
97
|
+
?power: Numeric | nil,
|
|
98
|
+
?alternative: Symbol | String
|
|
99
|
+
) -> PowerResult
|
|
100
|
+
|
|
101
|
+
def self.two_sample: (
|
|
102
|
+
?effect_size: Numeric | Symbol | String | nil,
|
|
103
|
+
?sample_size: Numeric | nil,
|
|
104
|
+
?alpha: Numeric | nil,
|
|
105
|
+
?power: Numeric | nil,
|
|
106
|
+
?alternative: Symbol | String
|
|
107
|
+
) -> PowerResult
|
|
108
|
+
|
|
109
|
+
def self.two_sample_unequal: (
|
|
110
|
+
?effect_size: Numeric | Symbol | String | nil,
|
|
111
|
+
?sample_size1: Numeric | nil,
|
|
112
|
+
?sample_size2: Numeric | nil,
|
|
113
|
+
?alpha: Numeric | nil,
|
|
114
|
+
?power: Numeric | nil,
|
|
115
|
+
?alternative: Symbol | String
|
|
116
|
+
) -> UnequalPowerResult
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
module TTest
|
|
120
|
+
def self.one_sample: (
|
|
121
|
+
?effect_size: Numeric | Symbol | String | nil,
|
|
122
|
+
?sample_size: Numeric | nil,
|
|
123
|
+
?alpha: Numeric | nil,
|
|
124
|
+
?power: Numeric | nil,
|
|
125
|
+
?alternative: Symbol | String
|
|
126
|
+
) -> PowerResult
|
|
127
|
+
|
|
128
|
+
def self.paired: (
|
|
129
|
+
?effect_size: Numeric | Symbol | String | nil,
|
|
130
|
+
?sample_size: Numeric | nil,
|
|
131
|
+
?alpha: Numeric | nil,
|
|
132
|
+
?power: Numeric | nil,
|
|
133
|
+
?alternative: Symbol | String
|
|
134
|
+
) -> PowerResult
|
|
135
|
+
|
|
136
|
+
def self.two_sample: (
|
|
137
|
+
?effect_size: Numeric | Symbol | String | nil,
|
|
138
|
+
?sample_size: Numeric | nil,
|
|
139
|
+
?alpha: Numeric | nil,
|
|
140
|
+
?power: Numeric | nil,
|
|
141
|
+
?alternative: Symbol | String
|
|
142
|
+
) -> PowerResult
|
|
143
|
+
|
|
144
|
+
def self.two_sample_unequal: (
|
|
145
|
+
?effect_size: Numeric | Symbol | String | nil,
|
|
146
|
+
?sample_size1: Numeric | nil,
|
|
147
|
+
?sample_size2: Numeric | nil,
|
|
148
|
+
?alpha: Numeric | nil,
|
|
149
|
+
?power: Numeric | nil,
|
|
150
|
+
?alternative: Symbol | String
|
|
151
|
+
) -> UnequalPowerResult
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
module Correlation
|
|
155
|
+
def self.solve: (
|
|
156
|
+
?correlation: Numeric | Symbol | String | nil,
|
|
157
|
+
?sample_size: Numeric | nil,
|
|
158
|
+
?alpha: Numeric | nil,
|
|
159
|
+
?power: Numeric | nil,
|
|
160
|
+
?alternative: Symbol | String
|
|
161
|
+
) -> PowerResult
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
module SpecialFunctions
|
|
165
|
+
module Beta
|
|
166
|
+
def self.regularized: (Numeric x, a: Numeric, b: Numeric) -> Float
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
module Integration
|
|
171
|
+
module AdaptiveSimpson
|
|
172
|
+
def self.integrate: (
|
|
173
|
+
lower: Numeric,
|
|
174
|
+
upper: Numeric,
|
|
175
|
+
?tolerance: Numeric,
|
|
176
|
+
?max_depth: Integer
|
|
177
|
+
) { (Float) -> Numeric } -> Float
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
module Distributions
|
|
182
|
+
module Normal
|
|
183
|
+
def self.pdf: (Numeric x) -> Float
|
|
184
|
+
def self.cdf: (Numeric x) -> Float
|
|
185
|
+
def self.survival: (Numeric x) -> Float
|
|
186
|
+
def self.quantile: (Numeric probability) -> Float
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
module StudentT
|
|
190
|
+
def self.pdf: (Numeric x, degrees_of_freedom: Numeric) -> Float
|
|
191
|
+
def self.cdf: (Numeric x, degrees_of_freedom: Numeric) -> Float
|
|
192
|
+
def self.survival: (Numeric x, degrees_of_freedom: Numeric) -> Float
|
|
193
|
+
def self.quantile: (Numeric probability, degrees_of_freedom: Numeric) -> Float
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
module NoncentralT
|
|
197
|
+
def self.cdf: (
|
|
198
|
+
Numeric x,
|
|
199
|
+
degrees_of_freedom: Numeric,
|
|
200
|
+
noncentrality: Numeric
|
|
201
|
+
) -> Float
|
|
202
|
+
|
|
203
|
+
def self.survival: (
|
|
204
|
+
Numeric x,
|
|
205
|
+
degrees_of_freedom: Numeric,
|
|
206
|
+
noncentrality: Numeric
|
|
207
|
+
) -> Float
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
module FDistribution
|
|
211
|
+
def self.pdf: (
|
|
212
|
+
Numeric x,
|
|
213
|
+
numerator_df: Numeric,
|
|
214
|
+
denominator_df: Numeric
|
|
215
|
+
) -> Float
|
|
216
|
+
|
|
217
|
+
def self.cdf: (
|
|
218
|
+
Numeric x,
|
|
219
|
+
numerator_df: Numeric,
|
|
220
|
+
denominator_df: Numeric
|
|
221
|
+
) -> Float
|
|
222
|
+
|
|
223
|
+
def self.survival: (
|
|
224
|
+
Numeric x,
|
|
225
|
+
numerator_df: Numeric,
|
|
226
|
+
denominator_df: Numeric
|
|
227
|
+
) -> Float
|
|
228
|
+
|
|
229
|
+
def self.quantile: (
|
|
230
|
+
Numeric probability,
|
|
231
|
+
numerator_df: Numeric,
|
|
232
|
+
denominator_df: Numeric
|
|
233
|
+
) -> Float
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
module NoncentralF
|
|
237
|
+
def self.cdf: (
|
|
238
|
+
Numeric x,
|
|
239
|
+
numerator_df: Numeric,
|
|
240
|
+
denominator_df: Numeric,
|
|
241
|
+
noncentrality: Numeric
|
|
242
|
+
) -> Float
|
|
243
|
+
|
|
244
|
+
def self.survival: (
|
|
245
|
+
Numeric x,
|
|
246
|
+
numerator_df: Numeric,
|
|
247
|
+
denominator_df: Numeric,
|
|
248
|
+
noncentrality: Numeric
|
|
249
|
+
) -> Float
|
|
250
|
+
end
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
module Solvers
|
|
254
|
+
module Bisection
|
|
255
|
+
def self.solve: (
|
|
256
|
+
lower: Numeric,
|
|
257
|
+
upper: Numeric,
|
|
258
|
+
?absolute_tolerance: Float,
|
|
259
|
+
?relative_tolerance: Float,
|
|
260
|
+
?max_iterations: Integer
|
|
261
|
+
) { (Float) -> Numeric } -> Float
|
|
262
|
+
end
|
|
263
|
+
end
|
|
264
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: stat_power
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0.alpha.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Diogo Ribeiro
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-09-19 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Native Ruby tools for statistical power analysis, sample-size determination,
|
|
14
|
+
effect-size calculations, and inverse power problems.
|
|
15
|
+
email:
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- CHANGELOG.md
|
|
21
|
+
- LICENSE
|
|
22
|
+
- README.md
|
|
23
|
+
- RELEASING.md
|
|
24
|
+
- ROADMAP.md
|
|
25
|
+
- docs/mathematical_conventions.md
|
|
26
|
+
- docs/pwr_parity.md
|
|
27
|
+
- lib/stat_power.rb
|
|
28
|
+
- lib/stat_power/correlation.rb
|
|
29
|
+
- lib/stat_power/distributions/f_distribution.rb
|
|
30
|
+
- lib/stat_power/distributions/noncentral_f.rb
|
|
31
|
+
- lib/stat_power/distributions/noncentral_t.rb
|
|
32
|
+
- lib/stat_power/distributions/normal.rb
|
|
33
|
+
- lib/stat_power/distributions/student_t.rb
|
|
34
|
+
- lib/stat_power/effect_size/conventional.rb
|
|
35
|
+
- lib/stat_power/effect_size/proportion.rb
|
|
36
|
+
- lib/stat_power/errors.rb
|
|
37
|
+
- lib/stat_power/integration/adaptive_simpson.rb
|
|
38
|
+
- lib/stat_power/normal_mean.rb
|
|
39
|
+
- lib/stat_power/power_result.rb
|
|
40
|
+
- lib/stat_power/proportion.rb
|
|
41
|
+
- lib/stat_power/result.rb
|
|
42
|
+
- lib/stat_power/solvers/bisection.rb
|
|
43
|
+
- lib/stat_power/special_functions/beta.rb
|
|
44
|
+
- lib/stat_power/t_test.rb
|
|
45
|
+
- lib/stat_power/t_test_unequal.rb
|
|
46
|
+
- lib/stat_power/unequal_power_result.rb
|
|
47
|
+
- lib/stat_power/version.rb
|
|
48
|
+
- sig/stat_power.rbs
|
|
49
|
+
homepage: https://github.com/DiogoRibeiro7/stat_power
|
|
50
|
+
licenses:
|
|
51
|
+
- MIT
|
|
52
|
+
metadata:
|
|
53
|
+
source_code_uri: https://github.com/DiogoRibeiro7/stat_power
|
|
54
|
+
changelog_uri: https://github.com/DiogoRibeiro7/stat_power/blob/main/CHANGELOG.md
|
|
55
|
+
documentation_uri: https://github.com/DiogoRibeiro7/stat_power#readme
|
|
56
|
+
rubygems_mfa_required: 'true'
|
|
57
|
+
post_install_message:
|
|
58
|
+
rdoc_options: []
|
|
59
|
+
require_paths:
|
|
60
|
+
- lib
|
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
62
|
+
requirements:
|
|
63
|
+
- - ">="
|
|
64
|
+
- !ruby/object:Gem::Version
|
|
65
|
+
version: '3.2'
|
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
|
+
requirements:
|
|
68
|
+
- - ">="
|
|
69
|
+
- !ruby/object:Gem::Version
|
|
70
|
+
version: '0'
|
|
71
|
+
requirements: []
|
|
72
|
+
rubygems_version: 3.5.22
|
|
73
|
+
signing_key:
|
|
74
|
+
specification_version: 4
|
|
75
|
+
summary: Statistical power analysis and sample-size determination for Ruby
|
|
76
|
+
test_files: []
|