statsample 0.18.0 → 1.0.0
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.
- data.tar.gz.sig +0 -0
- data/History.txt +23 -0
- data/Manifest.txt +28 -17
- data/Rakefile +3 -2
- data/benchmarks/correlation_matrix_15_variables.rb +31 -0
- data/benchmarks/correlation_matrix_5_variables.rb +32 -0
- data/benchmarks/correlation_matrix_methods/correlation_matrix.ds +0 -0
- data/benchmarks/correlation_matrix_methods/correlation_matrix.html +93 -0
- data/benchmarks/correlation_matrix_methods/correlation_matrix.rb +75 -0
- data/benchmarks/correlation_matrix_methods/correlation_matrix.xls +0 -0
- data/benchmarks/correlation_matrix_methods/correlation_matrix_gsl_ruby.ods +0 -0
- data/benchmarks/correlation_matrix_methods/correlation_matrix_with_graphics.ods +0 -0
- data/benchmarks/correlation_matrix_methods/results.ds +0 -0
- data/benchmarks/factor_map.rb +37 -0
- data/benchmarks/helpers_benchmark.rb +5 -0
- data/examples/boxplot.rb +13 -14
- data/examples/correlation_matrix.rb +16 -8
- data/examples/dataset.rb +13 -4
- data/examples/dominance_analysis.rb +23 -17
- data/examples/dominance_analysis_bootstrap.rb +28 -22
- data/examples/histogram.rb +8 -9
- data/examples/icc.rb +20 -21
- data/examples/levene.rb +10 -4
- data/examples/multiple_regression.rb +9 -28
- data/examples/multivariate_correlation.rb +9 -3
- data/examples/parallel_analysis.rb +20 -16
- data/examples/polychoric.rb +15 -9
- data/examples/principal_axis.rb +18 -6
- data/examples/reliability.rb +26 -13
- data/examples/scatterplot.rb +10 -6
- data/examples/t_test.rb +15 -6
- data/examples/tetrachoric.rb +9 -2
- data/examples/u_test.rb +12 -4
- data/examples/vector.rb +13 -2
- data/examples/velicer_map_test.rb +33 -26
- data/lib/statsample.rb +32 -12
- data/lib/statsample/analysis.rb +79 -0
- data/lib/statsample/analysis/suite.rb +72 -0
- data/lib/statsample/analysis/suitereportbuilder.rb +38 -0
- data/lib/statsample/bivariate.rb +70 -16
- data/lib/statsample/dataset.rb +25 -19
- data/lib/statsample/dominanceanalysis.rb +2 -2
- data/lib/statsample/factor.rb +2 -0
- data/lib/statsample/factor/map.rb +16 -10
- data/lib/statsample/factor/parallelanalysis.rb +9 -3
- data/lib/statsample/factor/pca.rb +28 -32
- data/lib/statsample/factor/rotation.rb +15 -8
- data/lib/statsample/graph/boxplot.rb +3 -4
- data/lib/statsample/graph/histogram.rb +2 -1
- data/lib/statsample/graph/scatterplot.rb +1 -0
- data/lib/statsample/matrix.rb +106 -16
- data/lib/statsample/regression.rb +4 -1
- data/lib/statsample/regression/binomial.rb +1 -1
- data/lib/statsample/regression/multiple/baseengine.rb +19 -9
- data/lib/statsample/regression/multiple/gslengine.rb +127 -126
- data/lib/statsample/regression/multiple/matrixengine.rb +8 -5
- data/lib/statsample/regression/multiple/rubyengine.rb +1 -1
- data/lib/statsample/regression/simple.rb +31 -6
- data/lib/statsample/reliability.rb +11 -3
- data/lib/statsample/reliability/scaleanalysis.rb +4 -4
- data/lib/statsample/shorthand.rb +81 -0
- data/lib/statsample/test/chisquare.rb +1 -1
- data/lib/statsample/vector.rb +163 -163
- data/lib/statsample/vector/gsl.rb +106 -0
- data/references.txt +2 -2
- data/{data → test/fixtures}/crime.txt +0 -0
- data/{data → test/fixtures}/hartman_23.matrix +0 -0
- data/{data → test/fixtures}/repeated_fields.csv +0 -0
- data/{data → test/fixtures}/test_binomial.csv +0 -0
- data/test/{test_csv.csv → fixtures/test_csv.csv} +0 -0
- data/test/{test_xls.xls → fixtures/test_xls.xls} +0 -0
- data/{data → test/fixtures}/tetmat_matrix.txt +0 -0
- data/{data → test/fixtures}/tetmat_test.txt +0 -0
- data/test/helpers_tests.rb +18 -2
- data/test/test_analysis.rb +118 -0
- data/test/test_anovatwoway.rb +1 -1
- data/test/test_anovatwowaywithdataset.rb +1 -1
- data/test/test_anovawithvectors.rb +1 -2
- data/test/test_bartlettsphericity.rb +1 -2
- data/test/test_bivariate.rb +64 -22
- data/test/test_codification.rb +1 -2
- data/test/test_crosstab.rb +1 -2
- data/test/test_csv.rb +3 -4
- data/test/test_dataset.rb +24 -3
- data/test/test_dominance_analysis.rb +1 -2
- data/test/test_factor.rb +8 -69
- data/test/test_factor_map.rb +43 -0
- data/test/test_factor_pa.rb +54 -0
- data/test/test_ggobi.rb +1 -1
- data/test/test_gsl.rb +12 -18
- data/test/test_histogram.rb +1 -2
- data/test/test_logit.rb +62 -18
- data/test/test_matrix.rb +4 -5
- data/test/test_mle.rb +3 -4
- data/test/test_regression.rb +21 -2
- data/test/test_reliability.rb +3 -3
- data/test/test_reliability_icc.rb +1 -1
- data/test/test_reliability_skillscale.rb +20 -4
- data/test/test_resample.rb +1 -2
- data/test/test_rserve_extension.rb +1 -2
- data/test/test_srs.rb +1 -2
- data/test/test_statistics.rb +1 -2
- data/test/test_stest.rb +1 -2
- data/test/test_stratified.rb +1 -2
- data/test/test_test_f.rb +1 -2
- data/test/test_test_t.rb +1 -2
- data/test/test_umannwhitney.rb +1 -2
- data/test/test_vector.rb +117 -18
- data/test/test_xls.rb +2 -3
- data/web/Rakefile +39 -0
- metadata +109 -29
- metadata.gz.sig +0 -0
- data/examples/parallel_analysis_tetrachoric.rb +0 -31
- data/lib/distribution.rb +0 -25
- data/lib/distribution/chisquare.rb +0 -23
- data/lib/distribution/f.rb +0 -35
- data/lib/distribution/normal.rb +0 -60
- data/lib/distribution/normalbivariate.rb +0 -284
- data/lib/distribution/normalmultivariate.rb +0 -73
- data/lib/distribution/t.rb +0 -55
- data/test/test_distribution.rb +0 -73
metadata
CHANGED
|
@@ -3,10 +3,10 @@ name: statsample
|
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
|
5
5
|
segments:
|
|
6
|
+
- 1
|
|
6
7
|
- 0
|
|
7
|
-
- 18
|
|
8
8
|
- 0
|
|
9
|
-
version: 0.
|
|
9
|
+
version: 1.0.0
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Claudio Bustos
|
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
|
35
35
|
rpP0jjs0
|
|
36
36
|
-----END CERTIFICATE-----
|
|
37
37
|
|
|
38
|
-
date: 2011-01-
|
|
38
|
+
date: 2011-01-27 00:00:00 -03:00
|
|
39
39
|
default_executable:
|
|
40
40
|
dependencies:
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
@@ -168,7 +168,7 @@ dependencies:
|
|
|
168
168
|
type: :runtime
|
|
169
169
|
version_requirements: *id009
|
|
170
170
|
- !ruby/object:Gem::Dependency
|
|
171
|
-
name:
|
|
171
|
+
name: distribution
|
|
172
172
|
prerelease: false
|
|
173
173
|
requirement: &id010 !ruby/object:Gem::Requirement
|
|
174
174
|
none: false
|
|
@@ -177,11 +177,13 @@ dependencies:
|
|
|
177
177
|
- !ruby/object:Gem::Version
|
|
178
178
|
segments:
|
|
179
179
|
- 0
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
- 2
|
|
181
|
+
- 0
|
|
182
|
+
version: 0.2.0
|
|
183
|
+
type: :runtime
|
|
182
184
|
version_requirements: *id010
|
|
183
185
|
- !ruby/object:Gem::Dependency
|
|
184
|
-
name:
|
|
186
|
+
name: hoe
|
|
185
187
|
prerelease: false
|
|
186
188
|
requirement: &id011 !ruby/object:Gem::Requirement
|
|
187
189
|
none: false
|
|
@@ -194,9 +196,22 @@ dependencies:
|
|
|
194
196
|
type: :development
|
|
195
197
|
version_requirements: *id011
|
|
196
198
|
- !ruby/object:Gem::Dependency
|
|
197
|
-
name:
|
|
199
|
+
name: shoulda
|
|
198
200
|
prerelease: false
|
|
199
201
|
requirement: &id012 !ruby/object:Gem::Requirement
|
|
202
|
+
none: false
|
|
203
|
+
requirements:
|
|
204
|
+
- - ~>
|
|
205
|
+
- !ruby/object:Gem::Version
|
|
206
|
+
segments:
|
|
207
|
+
- 0
|
|
208
|
+
version: "0"
|
|
209
|
+
type: :development
|
|
210
|
+
version_requirements: *id012
|
|
211
|
+
- !ruby/object:Gem::Dependency
|
|
212
|
+
name: minitest
|
|
213
|
+
prerelease: false
|
|
214
|
+
requirement: &id013 !ruby/object:Gem::Requirement
|
|
200
215
|
none: false
|
|
201
216
|
requirements:
|
|
202
217
|
- - ~>
|
|
@@ -206,11 +221,63 @@ dependencies:
|
|
|
206
221
|
- 0
|
|
207
222
|
version: "2.0"
|
|
208
223
|
type: :development
|
|
209
|
-
version_requirements: *
|
|
224
|
+
version_requirements: *id013
|
|
225
|
+
- !ruby/object:Gem::Dependency
|
|
226
|
+
name: rserve-client
|
|
227
|
+
prerelease: false
|
|
228
|
+
requirement: &id014 !ruby/object:Gem::Requirement
|
|
229
|
+
none: false
|
|
230
|
+
requirements:
|
|
231
|
+
- - ~>
|
|
232
|
+
- !ruby/object:Gem::Version
|
|
233
|
+
segments:
|
|
234
|
+
- 0
|
|
235
|
+
version: "0"
|
|
236
|
+
type: :development
|
|
237
|
+
version_requirements: *id014
|
|
238
|
+
- !ruby/object:Gem::Dependency
|
|
239
|
+
name: gettext
|
|
240
|
+
prerelease: false
|
|
241
|
+
requirement: &id015 !ruby/object:Gem::Requirement
|
|
242
|
+
none: false
|
|
243
|
+
requirements:
|
|
244
|
+
- - ~>
|
|
245
|
+
- !ruby/object:Gem::Version
|
|
246
|
+
segments:
|
|
247
|
+
- 0
|
|
248
|
+
version: "0"
|
|
249
|
+
type: :development
|
|
250
|
+
version_requirements: *id015
|
|
251
|
+
- !ruby/object:Gem::Dependency
|
|
252
|
+
name: mocha
|
|
253
|
+
prerelease: false
|
|
254
|
+
requirement: &id016 !ruby/object:Gem::Requirement
|
|
255
|
+
none: false
|
|
256
|
+
requirements:
|
|
257
|
+
- - ~>
|
|
258
|
+
- !ruby/object:Gem::Version
|
|
259
|
+
segments:
|
|
260
|
+
- 0
|
|
261
|
+
version: "0"
|
|
262
|
+
type: :development
|
|
263
|
+
version_requirements: *id016
|
|
264
|
+
- !ruby/object:Gem::Dependency
|
|
265
|
+
name: hoe-git
|
|
266
|
+
prerelease: false
|
|
267
|
+
requirement: &id017 !ruby/object:Gem::Requirement
|
|
268
|
+
none: false
|
|
269
|
+
requirements:
|
|
270
|
+
- - ~>
|
|
271
|
+
- !ruby/object:Gem::Version
|
|
272
|
+
segments:
|
|
273
|
+
- 0
|
|
274
|
+
version: "0"
|
|
275
|
+
type: :development
|
|
276
|
+
version_requirements: *id017
|
|
210
277
|
- !ruby/object:Gem::Dependency
|
|
211
278
|
name: hoe
|
|
212
279
|
prerelease: false
|
|
213
|
-
requirement: &
|
|
280
|
+
requirement: &id018 !ruby/object:Gem::Requirement
|
|
214
281
|
none: false
|
|
215
282
|
requirements:
|
|
216
283
|
- - ">="
|
|
@@ -221,7 +288,7 @@ dependencies:
|
|
|
221
288
|
- 0
|
|
222
289
|
version: 2.8.0
|
|
223
290
|
type: :development
|
|
224
|
-
version_requirements: *
|
|
291
|
+
version_requirements: *id018
|
|
225
292
|
description: |-
|
|
226
293
|
A suite for basic and advanced statistics on Ruby. Tested on Ruby 1.8.7, 1.9.1, 1.9.2 (April, 2010) and JRuby 1.4 (Ruby 1.8.7 compatible).
|
|
227
294
|
|
|
@@ -258,14 +325,19 @@ files:
|
|
|
258
325
|
- Manifest.txt
|
|
259
326
|
- README.txt
|
|
260
327
|
- Rakefile
|
|
328
|
+
- benchmarks/correlation_matrix_15_variables.rb
|
|
329
|
+
- benchmarks/correlation_matrix_5_variables.rb
|
|
330
|
+
- benchmarks/correlation_matrix_methods/correlation_matrix.ds
|
|
331
|
+
- benchmarks/correlation_matrix_methods/correlation_matrix.html
|
|
332
|
+
- benchmarks/correlation_matrix_methods/correlation_matrix.rb
|
|
333
|
+
- benchmarks/correlation_matrix_methods/correlation_matrix.xls
|
|
334
|
+
- benchmarks/correlation_matrix_methods/correlation_matrix_gsl_ruby.ods
|
|
335
|
+
- benchmarks/correlation_matrix_methods/correlation_matrix_with_graphics.ods
|
|
336
|
+
- benchmarks/correlation_matrix_methods/results.ds
|
|
337
|
+
- benchmarks/factor_map.rb
|
|
338
|
+
- benchmarks/helpers_benchmark.rb
|
|
261
339
|
- bin/statsample
|
|
262
|
-
- data/crime.txt
|
|
263
|
-
- data/hartman_23.matrix
|
|
264
340
|
- data/locale/es/LC_MESSAGES/statsample.mo
|
|
265
|
-
- data/repeated_fields.csv
|
|
266
|
-
- data/test_binomial.csv
|
|
267
|
-
- data/tetmat_matrix.txt
|
|
268
|
-
- data/tetmat_test.txt
|
|
269
341
|
- doc_latex/manual/equations.tex
|
|
270
342
|
- examples/boxplot.rb
|
|
271
343
|
- examples/correlation_matrix.rb
|
|
@@ -278,7 +350,6 @@ files:
|
|
|
278
350
|
- examples/multiple_regression.rb
|
|
279
351
|
- examples/multivariate_correlation.rb
|
|
280
352
|
- examples/parallel_analysis.rb
|
|
281
|
-
- examples/parallel_analysis_tetrachoric.rb
|
|
282
353
|
- examples/polychoric.rb
|
|
283
354
|
- examples/principal_axis.rb
|
|
284
355
|
- examples/reliability.rb
|
|
@@ -289,15 +360,11 @@ files:
|
|
|
289
360
|
- examples/vector.rb
|
|
290
361
|
- examples/velicer_map_test.rb
|
|
291
362
|
- grab_references.rb
|
|
292
|
-
- lib/distribution.rb
|
|
293
|
-
- lib/distribution/chisquare.rb
|
|
294
|
-
- lib/distribution/f.rb
|
|
295
|
-
- lib/distribution/normal.rb
|
|
296
|
-
- lib/distribution/normalbivariate.rb
|
|
297
|
-
- lib/distribution/normalmultivariate.rb
|
|
298
|
-
- lib/distribution/t.rb
|
|
299
363
|
- lib/spss.rb
|
|
300
364
|
- lib/statsample.rb
|
|
365
|
+
- lib/statsample/analysis.rb
|
|
366
|
+
- lib/statsample/analysis/suite.rb
|
|
367
|
+
- lib/statsample/analysis/suitereportbuilder.rb
|
|
301
368
|
- lib/statsample/anova.rb
|
|
302
369
|
- lib/statsample/anova/oneway.rb
|
|
303
370
|
- lib/statsample/anova/twoway.rb
|
|
@@ -346,6 +413,7 @@ files:
|
|
|
346
413
|
- lib/statsample/reliability/skillscaleanalysis.rb
|
|
347
414
|
- lib/statsample/resample.rb
|
|
348
415
|
- lib/statsample/rserve_extension.rb
|
|
416
|
+
- lib/statsample/shorthand.rb
|
|
349
417
|
- lib/statsample/srs.rb
|
|
350
418
|
- lib/statsample/test.rb
|
|
351
419
|
- lib/statsample/test/bartlettsphericity.rb
|
|
@@ -355,6 +423,7 @@ files:
|
|
|
355
423
|
- lib/statsample/test/t.rb
|
|
356
424
|
- lib/statsample/test/umannwhitney.rb
|
|
357
425
|
- lib/statsample/vector.rb
|
|
426
|
+
- lib/statsample/vector/gsl.rb
|
|
358
427
|
- po/es/statsample.mo
|
|
359
428
|
- po/es/statsample.po
|
|
360
429
|
- po/statsample.pot
|
|
@@ -362,7 +431,16 @@ files:
|
|
|
362
431
|
- setup.rb
|
|
363
432
|
- test/fixtures/bank2.dat
|
|
364
433
|
- test/fixtures/correlation_matrix.rb
|
|
434
|
+
- test/fixtures/crime.txt
|
|
435
|
+
- test/fixtures/hartman_23.matrix
|
|
436
|
+
- test/fixtures/repeated_fields.csv
|
|
437
|
+
- test/fixtures/test_binomial.csv
|
|
438
|
+
- test/fixtures/test_csv.csv
|
|
439
|
+
- test/fixtures/test_xls.xls
|
|
440
|
+
- test/fixtures/tetmat_matrix.txt
|
|
441
|
+
- test/fixtures/tetmat_test.txt
|
|
365
442
|
- test/helpers_tests.rb
|
|
443
|
+
- test/test_analysis.rb
|
|
366
444
|
- test/test_anovaoneway.rb
|
|
367
445
|
- test/test_anovatwoway.rb
|
|
368
446
|
- test/test_anovatwowaywithdataset.rb
|
|
@@ -371,12 +449,12 @@ files:
|
|
|
371
449
|
- test/test_bivariate.rb
|
|
372
450
|
- test/test_codification.rb
|
|
373
451
|
- test/test_crosstab.rb
|
|
374
|
-
- test/test_csv.csv
|
|
375
452
|
- test/test_csv.rb
|
|
376
453
|
- test/test_dataset.rb
|
|
377
|
-
- test/test_distribution.rb
|
|
378
454
|
- test/test_dominance_analysis.rb
|
|
379
455
|
- test/test_factor.rb
|
|
456
|
+
- test/test_factor_map.rb
|
|
457
|
+
- test/test_factor_pa.rb
|
|
380
458
|
- test/test_ggobi.rb
|
|
381
459
|
- test/test_gsl.rb
|
|
382
460
|
- test/test_histogram.rb
|
|
@@ -399,7 +477,7 @@ files:
|
|
|
399
477
|
- test/test_umannwhitney.rb
|
|
400
478
|
- test/test_vector.rb
|
|
401
479
|
- test/test_xls.rb
|
|
402
|
-
-
|
|
480
|
+
- web/Rakefile
|
|
403
481
|
has_rdoc: true
|
|
404
482
|
homepage: http://ruby-statsample.rubyforge.org/
|
|
405
483
|
licenses: []
|
|
@@ -453,16 +531,18 @@ specification_version: 3
|
|
|
453
531
|
summary: A suite for basic and advanced statistics on Ruby
|
|
454
532
|
test_files:
|
|
455
533
|
- test/test_bivariate.rb
|
|
534
|
+
- test/test_factor_pa.rb
|
|
456
535
|
- test/test_dominance_analysis.rb
|
|
457
536
|
- test/test_factor.rb
|
|
458
537
|
- test/test_codification.rb
|
|
459
538
|
- test/test_anovatwowaywithdataset.rb
|
|
460
539
|
- test/test_umannwhitney.rb
|
|
540
|
+
- test/test_factor_map.rb
|
|
461
541
|
- test/test_anovawithvectors.rb
|
|
462
542
|
- test/test_crosstab.rb
|
|
463
|
-
- test/test_distribution.rb
|
|
464
543
|
- test/test_rserve_extension.rb
|
|
465
544
|
- test/test_csv.rb
|
|
545
|
+
- test/test_analysis.rb
|
|
466
546
|
- test/test_matrix.rb
|
|
467
547
|
- test/test_gsl.rb
|
|
468
548
|
- test/test_bartlettsphericity.rb
|
metadata.gz.sig
CHANGED
|
Binary file
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/ruby
|
|
2
|
-
$:.unshift(File.dirname(__FILE__)+'/../lib/')
|
|
3
|
-
|
|
4
|
-
require 'statsample'
|
|
5
|
-
require 'statsample/bivariate/tetrachoric'
|
|
6
|
-
samples=1000
|
|
7
|
-
variables=10
|
|
8
|
-
rng = GSL::Rng.alloc()
|
|
9
|
-
f1=samples.times.collect {rng.ugaussian()}.to_scale
|
|
10
|
-
f2=samples.times.collect {rng.ugaussian()}.to_scale
|
|
11
|
-
f3=samples.times.collect {rng.ugaussian()}.to_scale
|
|
12
|
-
|
|
13
|
-
vectors={}
|
|
14
|
-
|
|
15
|
-
variables.times do |i|
|
|
16
|
-
vectors["v#{i}"]=samples.times.collect {|nv| f1[nv]*(i-30)+f2[nv]*(i+30)+f3[nv]*(i+15) + rng.ugaussian() > 0 ? 1 : 0}.to_scale
|
|
17
|
-
end
|
|
18
|
-
ds=vectors.to_dataset
|
|
19
|
-
|
|
20
|
-
pa=Statsample::Factor::ParallelAnalysis.new(ds, :iterations=>10, :matrix_method=>:tetrachoric_correlation_matrix, :debug=>true)
|
|
21
|
-
|
|
22
|
-
pca=Statsample::Factor::PCA.new(Statsample::Bivariate.tetrachoric_correlation_matrix(ds))
|
|
23
|
-
rb=ReportBuilder.new(:name=>"Parallel Analysis with simulation") do |g|
|
|
24
|
-
g.text("There are 3 real factors on data")
|
|
25
|
-
g.parse_element(pca)
|
|
26
|
-
g.text("Traditional Kaiser criterion (k>1) returns #{pca.m} factors")
|
|
27
|
-
g.parse_element(pa)
|
|
28
|
-
g.text("Parallel Analysis returns #{pa.number_of_factors} factors to preserve")
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
puts rb.to_text
|
data/lib/distribution.rb
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
begin
|
|
2
|
-
require 'statistics2'
|
|
3
|
-
rescue LoadError
|
|
4
|
-
puts "You should install statistics2"
|
|
5
|
-
end
|
|
6
|
-
# Several distributions modules to calculate cdf, inverse cdf and pdf
|
|
7
|
-
# See Distribution::Pdf for interface.
|
|
8
|
-
#
|
|
9
|
-
# Usage:
|
|
10
|
-
# Distribution::Normal.cdf(1.96)
|
|
11
|
-
# => 0.97500210485178
|
|
12
|
-
# Distribution::Normal.p_value(0.95)
|
|
13
|
-
# => 1.64485364660836
|
|
14
|
-
module Distribution
|
|
15
|
-
def self.has_gsl?
|
|
16
|
-
Statsample.has_gsl?
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
autoload(:ChiSquare, 'distribution/chisquare')
|
|
20
|
-
autoload(:T, 'distribution/t')
|
|
21
|
-
autoload(:F, 'distribution/f')
|
|
22
|
-
autoload(:Normal, 'distribution/normal')
|
|
23
|
-
autoload(:NormalBivariate, 'distribution/normalbivariate')
|
|
24
|
-
# autoload(:NormalMultivariate, 'distribution/normalmultivariate')
|
|
25
|
-
end
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
module Distribution
|
|
2
|
-
# Calculate cdf and inverse cdf for Chi Square Distribution.
|
|
3
|
-
#
|
|
4
|
-
# Based on Statistics2 module
|
|
5
|
-
#
|
|
6
|
-
module ChiSquare
|
|
7
|
-
class << self
|
|
8
|
-
# Return the P-value of the corresponding integral with
|
|
9
|
-
# k degrees of freedom
|
|
10
|
-
def p_value(pr,k)
|
|
11
|
-
Statistics2.pchi2X_(k.to_i, pr)
|
|
12
|
-
end
|
|
13
|
-
# Chi-square cumulative distribution function (cdf).
|
|
14
|
-
#
|
|
15
|
-
# Returns the integral of Chi-squared distribution
|
|
16
|
-
# with k degrees of freedom over [0, x]
|
|
17
|
-
#
|
|
18
|
-
def cdf(x, k)
|
|
19
|
-
Statistics2.chi2dist(k.to_i,x)
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
data/lib/distribution/f.rb
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
module Distribution
|
|
2
|
-
# Calculate cdf and inverse cdf for Fisher Distribution.
|
|
3
|
-
# Uses Statistics2 module
|
|
4
|
-
module F
|
|
5
|
-
class << self
|
|
6
|
-
# Return the P-value of the corresponding integral with
|
|
7
|
-
# k degrees of freedom
|
|
8
|
-
#
|
|
9
|
-
# Distribution::F.p_value(0.95,1,2)
|
|
10
|
-
def p_value(pr,k1,k2)
|
|
11
|
-
# Statistics2 has some troubles with extreme f values
|
|
12
|
-
if Distribution.has_gsl?
|
|
13
|
-
GSL::Cdf.fdist_Pinv(pr,k1,k2)
|
|
14
|
-
else
|
|
15
|
-
#puts "F:#{k1}, #{k2},#{pr}"
|
|
16
|
-
Statistics2.pfdist(k1,k2, pr)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
# F cumulative distribution function (cdf).
|
|
20
|
-
#
|
|
21
|
-
# Returns the integral of F-distribution
|
|
22
|
-
# with k1 and k2 degrees of freedom
|
|
23
|
-
# over [0, x].
|
|
24
|
-
# Distribution::F.cdf(20,3,2)
|
|
25
|
-
#
|
|
26
|
-
def cdf(x, k1, k2)
|
|
27
|
-
if Distribution.has_gsl?
|
|
28
|
-
GSL::Cdf.fdist_P(x.to_f,k1,k2)
|
|
29
|
-
else
|
|
30
|
-
Statistics2.fdist(k1, k2,x)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
data/lib/distribution/normal.rb
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
module Distribution
|
|
2
|
-
# Calculate cdf and inverse cdf for Normal Distribution.
|
|
3
|
-
# Uses Statistics2 module
|
|
4
|
-
module Normal
|
|
5
|
-
class << self
|
|
6
|
-
# Return a proc which return a random number within a gaussian distribution -> N(0,1)
|
|
7
|
-
# == Reference:
|
|
8
|
-
# * http://www.taygeta.com/random/gaussian.html
|
|
9
|
-
def rng_ugaussian
|
|
10
|
-
if Distribution.has_gsl?
|
|
11
|
-
rng=GSL::Rng.alloc()
|
|
12
|
-
lambda { rng.ugaussian()}
|
|
13
|
-
else
|
|
14
|
-
returned,y1,y2=0,0,0
|
|
15
|
-
lambda {
|
|
16
|
-
if returned==0
|
|
17
|
-
begin
|
|
18
|
-
x1 = 2.0 * rand - 1.0
|
|
19
|
-
x2 = 2.0 * rand - 1.0
|
|
20
|
-
w = x1 * x1 + x2 * x2
|
|
21
|
-
end while ( w >= 1.0 )
|
|
22
|
-
w = Math::sqrt( (-2.0 * Math::log( w ) ) / w )
|
|
23
|
-
y1 = x1 * w
|
|
24
|
-
y2 = x2 * w
|
|
25
|
-
returned=1
|
|
26
|
-
y1
|
|
27
|
-
else
|
|
28
|
-
returned=0
|
|
29
|
-
y2
|
|
30
|
-
end
|
|
31
|
-
}
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
# Return the P-value of the corresponding integral
|
|
35
|
-
def p_value(pr)
|
|
36
|
-
Statistics2.pnormaldist(pr)
|
|
37
|
-
end
|
|
38
|
-
# Normal cumulative distribution function (cdf).
|
|
39
|
-
#
|
|
40
|
-
# Returns the integral of normal distribution
|
|
41
|
-
# over (-Infty, x].
|
|
42
|
-
#
|
|
43
|
-
def cdf(x)
|
|
44
|
-
Statistics2.normaldist(x)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
if Distribution.has_gsl?
|
|
48
|
-
alias :cdf_ruby :cdf
|
|
49
|
-
def cdf(x) # :nodoc:
|
|
50
|
-
GSL::Cdf::gaussian_P(x)
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
# Normal probability density function (pdf)
|
|
54
|
-
# With x=0 and sigma=1
|
|
55
|
-
def pdf(x)
|
|
56
|
-
(1.0/Math::sqrt(2*Math::PI))*Math::exp(-(x**2/2.0))
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|