statsample 1.5.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.build.sh +15 -0
- data/.gitignore +1 -0
- data/.travis.yml +19 -7
- data/CONTRIBUTING.md +33 -0
- data/History.txt +5 -0
- data/README.md +41 -53
- data/benchmarks/correlation_matrix_15_variables.rb +6 -5
- data/benchmarks/correlation_matrix_5_variables.rb +6 -5
- data/benchmarks/correlation_matrix_methods/correlation_matrix.rb +23 -26
- data/examples/boxplot.rb +17 -5
- data/examples/correlation_matrix.rb +36 -7
- data/examples/dataset.rb +25 -5
- data/examples/dominance_analysis.rb +8 -7
- data/examples/dominance_analysis_bootstrap.rb +16 -11
- data/examples/histogram.rb +16 -2
- data/examples/icc.rb +5 -6
- data/examples/levene.rb +17 -3
- data/examples/multiple_regression.rb +6 -3
- data/examples/parallel_analysis.rb +11 -6
- data/examples/polychoric.rb +26 -13
- data/examples/principal_axis.rb +8 -4
- data/examples/reliability.rb +10 -10
- data/examples/scatterplot.rb +8 -0
- data/examples/t_test.rb +7 -0
- data/examples/u_test.rb +10 -2
- data/examples/vector.rb +9 -6
- data/examples/velicer_map_test.rb +12 -8
- data/lib/statsample.rb +13 -47
- data/lib/statsample/analysis/suite.rb +1 -1
- data/lib/statsample/anova/oneway.rb +6 -6
- data/lib/statsample/anova/twoway.rb +26 -24
- data/lib/statsample/bivariate.rb +78 -61
- data/lib/statsample/bivariate/pearson.rb +2 -2
- data/lib/statsample/codification.rb +45 -32
- data/lib/statsample/converter/csv.rb +15 -53
- data/lib/statsample/converter/spss.rb +6 -5
- data/lib/statsample/converters.rb +50 -211
- data/lib/statsample/crosstab.rb +26 -25
- data/lib/statsample/daru.rb +117 -0
- data/lib/statsample/dataset.rb +70 -942
- data/lib/statsample/dominanceanalysis.rb +16 -17
- data/lib/statsample/dominanceanalysis/bootstrap.rb +26 -28
- data/lib/statsample/factor/parallelanalysis.rb +17 -19
- data/lib/statsample/factor/pca.rb +21 -20
- data/lib/statsample/factor/principalaxis.rb +3 -3
- data/lib/statsample/graph/boxplot.rb +8 -16
- data/lib/statsample/graph/histogram.rb +4 -4
- data/lib/statsample/graph/scatterplot.rb +8 -7
- data/lib/statsample/histogram.rb +128 -119
- data/lib/statsample/matrix.rb +20 -16
- data/lib/statsample/multiset.rb +39 -38
- data/lib/statsample/regression.rb +3 -3
- data/lib/statsample/regression/multiple.rb +8 -10
- data/lib/statsample/regression/multiple/alglibengine.rb +96 -89
- data/lib/statsample/regression/multiple/baseengine.rb +32 -32
- data/lib/statsample/regression/multiple/gslengine.rb +33 -36
- data/lib/statsample/regression/multiple/matrixengine.rb +7 -9
- data/lib/statsample/regression/multiple/rubyengine.rb +39 -41
- data/lib/statsample/reliability.rb +23 -25
- data/lib/statsample/reliability/icc.rb +8 -7
- data/lib/statsample/reliability/multiscaleanalysis.rb +14 -12
- data/lib/statsample/reliability/scaleanalysis.rb +58 -60
- data/lib/statsample/reliability/skillscaleanalysis.rb +34 -29
- data/lib/statsample/resample.rb +1 -1
- data/lib/statsample/shorthand.rb +29 -25
- data/lib/statsample/test/kolmogorovsmirnov.rb +5 -3
- data/lib/statsample/test/levene.rb +28 -27
- data/lib/statsample/test/t.rb +7 -9
- data/lib/statsample/test/umannwhitney.rb +28 -28
- data/lib/statsample/test/wilcoxonsignedrank.rb +45 -43
- data/lib/statsample/vector.rb +70 -1013
- data/lib/statsample/version.rb +1 -1
- data/statsample.gemspec +12 -16
- data/test/helpers_tests.rb +1 -1
- data/test/test_analysis.rb +17 -17
- data/test/test_anova_contrast.rb +6 -6
- data/test/test_anovatwowaywithdataset.rb +8 -8
- data/test/test_anovawithvectors.rb +8 -8
- data/test/test_awesome_print_bug.rb +1 -1
- data/test/test_bartlettsphericity.rb +4 -4
- data/test/test_bivariate.rb +48 -43
- data/test/test_codification.rb +33 -33
- data/test/test_crosstab.rb +9 -9
- data/test/test_dataset.rb +28 -458
- data/test/test_factor.rb +46 -38
- data/test/test_factor_pa.rb +22 -13
- data/test/test_ggobi.rb +4 -4
- data/test/test_gsl.rb +4 -4
- data/test/test_histogram.rb +3 -3
- data/test/test_matrix.rb +13 -13
- data/test/test_multiset.rb +103 -91
- data/test/test_regression.rb +57 -52
- data/test/test_reliability.rb +55 -45
- data/test/test_reliability_icc.rb +8 -8
- data/test/test_reliability_skillscale.rb +26 -24
- data/test/test_resample.rb +1 -1
- data/test/test_statistics.rb +3 -13
- data/test/test_stest.rb +9 -9
- data/test/test_stratified.rb +3 -3
- data/test/test_test_t.rb +12 -12
- data/test/test_umannwhitney.rb +2 -2
- data/test/test_vector.rb +76 -613
- data/test/test_wilcoxonsignedrank.rb +4 -4
- metadata +57 -28
- data/lib/statsample/rserve_extension.rb +0 -20
- data/lib/statsample/vector/gsl.rb +0 -106
- data/test/fixtures/repeated_fields.csv +0 -7
- data/test/fixtures/scientific_notation.csv +0 -4
- data/test/fixtures/test_csv.csv +0 -7
- data/test/fixtures/test_xls.xls +0 -0
- data/test/test_csv.rb +0 -63
- data/test/test_rserve_extension.rb +0 -42
- data/test/test_xls.rb +0 -52
@@ -5,8 +5,8 @@ class StatsampleUMannWhitneyTestCase < Minitest::Test
|
|
5
5
|
context Statsample::Test::WilcoxonSignedRank do
|
6
6
|
context 'Example 1' do
|
7
7
|
setup do
|
8
|
-
@v1 = [110, 122, 125, 120, 140, 124, 123, 137, 135, 145]
|
9
|
-
@v2 = [125, 115, 130, 140, 140, 115, 140, 125, 140, 135]
|
8
|
+
@v1 = Daru::Vector.new([110, 122, 125, 120, 140, 124, 123, 137, 135, 145])
|
9
|
+
@v2 = Daru::Vector.new([125, 115, 130, 140, 140, 115, 140, 125, 140, 135])
|
10
10
|
@u = Statsample::Test::WilcoxonSignedRank.new(@v1, @v2)
|
11
11
|
end
|
12
12
|
should 'have same result using class or Test#u_mannwhitney' do
|
@@ -34,8 +34,8 @@ class StatsampleUMannWhitneyTestCase < Minitest::Test
|
|
34
34
|
|
35
35
|
context 'Example 2' do
|
36
36
|
setup do
|
37
|
-
@v2 = [78, 24, 64, 45, 64, 52, 30, 50, 64, 50, 78, 22, 84, 40, 90, 72]
|
38
|
-
@v1 = [78, 24, 62, 48, 68, 56, 25, 44, 56, 40, 68, 36, 68, 20, 58, 32]
|
37
|
+
@v2 = Daru::Vector.new([78, 24, 64, 45, 64, 52, 30, 50, 64, 50, 78, 22, 84, 40, 90, 72])
|
38
|
+
@v1 = Daru::Vector.new([78, 24, 62, 48, 68, 56, 25, 44, 56, 40, 68, 36, 68, 20, 58, 32])
|
39
39
|
@u = Statsample::Test::WilcoxonSignedRank.new(@v1, @v2)
|
40
40
|
end
|
41
41
|
should 'have same result using class or Test#u_mannwhitney' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statsample
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claudio Bustos
|
@@ -9,22 +9,36 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-06-
|
12
|
+
date: 2015-06-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: daru
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0.1'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0.1'
|
14
28
|
- !ruby/object:Gem::Dependency
|
15
29
|
name: spreadsheet
|
16
30
|
requirement: !ruby/object:Gem::Requirement
|
17
31
|
requirements:
|
18
32
|
- - "~>"
|
19
33
|
- !ruby/object:Gem::Version
|
20
|
-
version: 0.
|
34
|
+
version: 1.0.3
|
21
35
|
type: :runtime
|
22
36
|
prerelease: false
|
23
37
|
version_requirements: !ruby/object:Gem::Requirement
|
24
38
|
requirements:
|
25
39
|
- - "~>"
|
26
40
|
- !ruby/object:Gem::Version
|
27
|
-
version: 0.
|
41
|
+
version: 1.0.3
|
28
42
|
- !ruby/object:Gem::Dependency
|
29
43
|
name: reportbuilder
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,14 +87,14 @@ dependencies:
|
|
73
87
|
requirements:
|
74
88
|
- - "~>"
|
75
89
|
- !ruby/object:Gem::Version
|
76
|
-
version: '0.
|
90
|
+
version: '0.4'
|
77
91
|
type: :runtime
|
78
92
|
prerelease: false
|
79
93
|
version_requirements: !ruby/object:Gem::Requirement
|
80
94
|
requirements:
|
81
95
|
- - "~>"
|
82
96
|
- !ruby/object:Gem::Version
|
83
|
-
version: '0.
|
97
|
+
version: '0.4'
|
84
98
|
- !ruby/object:Gem::Dependency
|
85
99
|
name: rserve-client
|
86
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,14 +115,14 @@ dependencies:
|
|
101
115
|
requirements:
|
102
116
|
- - "~>"
|
103
117
|
- !ruby/object:Gem::Version
|
104
|
-
version: 0.
|
118
|
+
version: 0.6.1
|
105
119
|
type: :runtime
|
106
120
|
prerelease: false
|
107
121
|
version_requirements: !ruby/object:Gem::Requirement
|
108
122
|
requirements:
|
109
123
|
- - "~>"
|
110
124
|
- !ruby/object:Gem::Version
|
111
|
-
version: 0.
|
125
|
+
version: 0.6.1
|
112
126
|
- !ruby/object:Gem::Dependency
|
113
127
|
name: distribution
|
114
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -143,14 +157,14 @@ dependencies:
|
|
143
157
|
requirements:
|
144
158
|
- - "~>"
|
145
159
|
- !ruby/object:Gem::Version
|
146
|
-
version: '1.
|
160
|
+
version: '1.10'
|
147
161
|
type: :development
|
148
162
|
prerelease: false
|
149
163
|
version_requirements: !ruby/object:Gem::Requirement
|
150
164
|
requirements:
|
151
165
|
- - "~>"
|
152
166
|
- !ruby/object:Gem::Version
|
153
|
-
version: '1.
|
167
|
+
version: '1.10'
|
154
168
|
- !ruby/object:Gem::Dependency
|
155
169
|
name: rake
|
156
170
|
requirement: !ruby/object:Gem::Requirement
|
@@ -213,14 +227,14 @@ dependencies:
|
|
213
227
|
requirements:
|
214
228
|
- - "~>"
|
215
229
|
- !ruby/object:Gem::Version
|
216
|
-
version: '5.
|
230
|
+
version: '5.7'
|
217
231
|
type: :development
|
218
232
|
prerelease: false
|
219
233
|
version_requirements: !ruby/object:Gem::Requirement
|
220
234
|
requirements:
|
221
235
|
- - "~>"
|
222
236
|
- !ruby/object:Gem::Version
|
223
|
-
version: '5.
|
237
|
+
version: '5.7'
|
224
238
|
- !ruby/object:Gem::Dependency
|
225
239
|
name: gettext
|
226
240
|
requirement: !ruby/object:Gem::Requirement
|
@@ -249,6 +263,34 @@ dependencies:
|
|
249
263
|
- - "~>"
|
250
264
|
- !ruby/object:Gem::Version
|
251
265
|
version: '1.1'
|
266
|
+
- !ruby/object:Gem::Dependency
|
267
|
+
name: nmatrix
|
268
|
+
requirement: !ruby/object:Gem::Requirement
|
269
|
+
requirements:
|
270
|
+
- - "~>"
|
271
|
+
- !ruby/object:Gem::Version
|
272
|
+
version: 0.1.0
|
273
|
+
type: :development
|
274
|
+
prerelease: false
|
275
|
+
version_requirements: !ruby/object:Gem::Requirement
|
276
|
+
requirements:
|
277
|
+
- - "~>"
|
278
|
+
- !ruby/object:Gem::Version
|
279
|
+
version: 0.1.0
|
280
|
+
- !ruby/object:Gem::Dependency
|
281
|
+
name: gsl-nmatrix
|
282
|
+
requirement: !ruby/object:Gem::Requirement
|
283
|
+
requirements:
|
284
|
+
- - "~>"
|
285
|
+
- !ruby/object:Gem::Version
|
286
|
+
version: 1.17.0
|
287
|
+
type: :development
|
288
|
+
prerelease: false
|
289
|
+
version_requirements: !ruby/object:Gem::Requirement
|
290
|
+
requirements:
|
291
|
+
- - "~>"
|
292
|
+
- !ruby/object:Gem::Version
|
293
|
+
version: 1.17.0
|
252
294
|
description: |
|
253
295
|
A suite for basic and advanced statistics on Ruby. Tested on CRuby 1.9.3, 2.0.0
|
254
296
|
and 2.1.1. See `.travis.yml` for more information.
|
@@ -257,7 +299,6 @@ description: |
|
|
257
299
|
|
258
300
|
- Descriptive statistics: frequencies, median, mean,
|
259
301
|
standard error, skew, kurtosis (and many others).
|
260
|
-
- Imports and exports datasets from and to Excel, CSV and plain text files.
|
261
302
|
- Correlations: Pearson's r, Spearman's rank correlation (rho), point biserial,
|
262
303
|
tau a, tau b and gamma. Tetrachoric and Polychoric correlation provides by
|
263
304
|
statsample-bivariate-extension gem.
|
@@ -287,8 +328,10 @@ extra_rdoc_files:
|
|
287
328
|
- README.md
|
288
329
|
- references.txt
|
289
330
|
files:
|
331
|
+
- ".build.sh"
|
290
332
|
- ".gitignore"
|
291
333
|
- ".travis.yml"
|
334
|
+
- CONTRIBUTING.md
|
292
335
|
- Gemfile
|
293
336
|
- History.txt
|
294
337
|
- LICENSE.txt
|
@@ -344,6 +387,7 @@ files:
|
|
344
387
|
- lib/statsample/converter/spss.rb
|
345
388
|
- lib/statsample/converters.rb
|
346
389
|
- lib/statsample/crosstab.rb
|
390
|
+
- lib/statsample/daru.rb
|
347
391
|
- lib/statsample/dataset.rb
|
348
392
|
- lib/statsample/dominanceanalysis.rb
|
349
393
|
- lib/statsample/dominanceanalysis/bootstrap.rb
|
@@ -374,7 +418,6 @@ files:
|
|
374
418
|
- lib/statsample/reliability/scaleanalysis.rb
|
375
419
|
- lib/statsample/reliability/skillscaleanalysis.rb
|
376
420
|
- lib/statsample/resample.rb
|
377
|
-
- lib/statsample/rserve_extension.rb
|
378
421
|
- lib/statsample/shorthand.rb
|
379
422
|
- lib/statsample/srs.rb
|
380
423
|
- lib/statsample/test.rb
|
@@ -387,7 +430,6 @@ files:
|
|
387
430
|
- lib/statsample/test/umannwhitney.rb
|
388
431
|
- lib/statsample/test/wilcoxonsignedrank.rb
|
389
432
|
- lib/statsample/vector.rb
|
390
|
-
- lib/statsample/vector/gsl.rb
|
391
433
|
- lib/statsample/version.rb
|
392
434
|
- po/es/statsample.mo
|
393
435
|
- po/es/statsample.po
|
@@ -397,11 +439,7 @@ files:
|
|
397
439
|
- test/fixtures/bank2.dat
|
398
440
|
- test/fixtures/correlation_matrix.rb
|
399
441
|
- test/fixtures/hartman_23.matrix
|
400
|
-
- test/fixtures/repeated_fields.csv
|
401
|
-
- test/fixtures/scientific_notation.csv
|
402
442
|
- test/fixtures/stock_data.csv
|
403
|
-
- test/fixtures/test_csv.csv
|
404
|
-
- test/fixtures/test_xls.xls
|
405
443
|
- test/fixtures/tetmat_matrix.txt
|
406
444
|
- test/fixtures/tetmat_test.txt
|
407
445
|
- test/helpers_tests.rb
|
@@ -416,7 +454,6 @@ files:
|
|
416
454
|
- test/test_bivariate.rb
|
417
455
|
- test/test_codification.rb
|
418
456
|
- test/test_crosstab.rb
|
419
|
-
- test/test_csv.rb
|
420
457
|
- test/test_dataset.rb
|
421
458
|
- test/test_dominance_analysis.rb
|
422
459
|
- test/test_factor.rb
|
@@ -432,7 +469,6 @@ files:
|
|
432
469
|
- test/test_reliability_icc.rb
|
433
470
|
- test/test_reliability_skillscale.rb
|
434
471
|
- test/test_resample.rb
|
435
|
-
- test/test_rserve_extension.rb
|
436
472
|
- test/test_srs.rb
|
437
473
|
- test/test_statistics.rb
|
438
474
|
- test/test_stest.rb
|
@@ -443,7 +479,6 @@ files:
|
|
443
479
|
- test/test_umannwhitney.rb
|
444
480
|
- test/test_vector.rb
|
445
481
|
- test/test_wilcoxonsignedrank.rb
|
446
|
-
- test/test_xls.rb
|
447
482
|
homepage: https://github.com/sciruby/statsample
|
448
483
|
licenses: []
|
449
484
|
metadata: {}
|
@@ -452,12 +487,6 @@ post_install_message: |
|
|
452
487
|
|
453
488
|
Thanks for installing statsample.
|
454
489
|
|
455
|
-
On *nix, you could install statsample-optimization
|
456
|
-
to retrieve gems gsl, statistics2 and a C extension
|
457
|
-
to speed some methods.
|
458
|
-
|
459
|
-
$ [sudo] gem install statsample-optimization
|
460
|
-
|
461
490
|
*****************************************************
|
462
491
|
rdoc_options:
|
463
492
|
- "--main"
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# Several additions to Statsample objects, to support
|
2
|
-
# rserve-client
|
3
|
-
|
4
|
-
module Statsample
|
5
|
-
class Vector
|
6
|
-
def to_REXP
|
7
|
-
Rserve::REXP::Wrapper.wrap(data_with_nils)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
class Dataset
|
11
|
-
def to_REXP
|
12
|
-
names=@fields
|
13
|
-
data=@fields.map {|f|
|
14
|
-
Rserve::REXP::Wrapper.wrap(@vectors[f].data_with_nils)
|
15
|
-
}
|
16
|
-
l=Rserve::Rlist.new(data,names)
|
17
|
-
Rserve::REXP.create_data_frame(l)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,106 +0,0 @@
|
|
1
|
-
module Statsample
|
2
|
-
class Vector
|
3
|
-
module GSL_
|
4
|
-
def clear_gsl
|
5
|
-
@gsl=nil
|
6
|
-
end
|
7
|
-
|
8
|
-
def set_valid_data
|
9
|
-
clear_gsl
|
10
|
-
set_valid_data_ruby
|
11
|
-
end
|
12
|
-
def push(v)
|
13
|
-
# If data is GSL::Vector, should be converted first to an Array
|
14
|
-
if @data.is_a? GSL::Vector
|
15
|
-
@data=@data.to_a
|
16
|
-
end
|
17
|
-
push_ruby(v)
|
18
|
-
end
|
19
|
-
|
20
|
-
def gsl
|
21
|
-
@gsl||=GSL::Vector.alloc(@numeric_data) if @numeric_data.size>0
|
22
|
-
end
|
23
|
-
|
24
|
-
alias :to_gsl :gsl
|
25
|
-
def vector_standarized_compute(m,sd)
|
26
|
-
if flawed?
|
27
|
-
vector_standarized_compute_ruby(m,sd)
|
28
|
-
else
|
29
|
-
gsl.collect {|x| (x.to_f - m).quo(sd)}.to_numeric
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def vector_centered_compute(m)
|
34
|
-
if flawed?
|
35
|
-
vector_centered_compute_ruby(m)
|
36
|
-
else
|
37
|
-
gsl.collect {|x| (x.to_f - m)}.to_numeric
|
38
|
-
end
|
39
|
-
end
|
40
|
-
def sample_with_replacement(sample=1)
|
41
|
-
if(@type!=:numeric)
|
42
|
-
sample_with_replacement_ruby(sample)
|
43
|
-
else
|
44
|
-
r = GSL::Rng.alloc(GSL::Rng::MT19937,rand(10000))
|
45
|
-
Statsample::Vector.new(r.sample(gsl, sample).to_a,:numeric)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def sample_without_replacement(sample=1)
|
50
|
-
if(@type!=:numeric)
|
51
|
-
sample_without_replacement_ruby(sample)
|
52
|
-
else
|
53
|
-
r = GSL::Rng.alloc(GSL::Rng::MT19937,rand(10000))
|
54
|
-
r.choose(gsl, sample).to_a
|
55
|
-
end
|
56
|
-
end
|
57
|
-
def median
|
58
|
-
if @type!=:numeric
|
59
|
-
median_ruby
|
60
|
-
else
|
61
|
-
sorted=GSL::Vector.alloc(@numeric_data.sort)
|
62
|
-
GSL::Stats::median_from_sorted_data(sorted)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def sum
|
67
|
-
check_type :numeric
|
68
|
-
gsl.nil? ? nil : gsl.sum
|
69
|
-
end
|
70
|
-
def mean
|
71
|
-
check_type :numeric
|
72
|
-
gsl.nil? ? nil : gsl.mean
|
73
|
-
end
|
74
|
-
def variance_sample(m=nil)
|
75
|
-
check_type :numeric
|
76
|
-
m||=mean
|
77
|
-
gsl.nil? ? nil : gsl.variance_m
|
78
|
-
end
|
79
|
-
|
80
|
-
def standard_deviation_sample(m=nil)
|
81
|
-
check_type :numeric
|
82
|
-
m||=mean
|
83
|
-
gsl.nil? ? nil : gsl.sd(m)
|
84
|
-
end
|
85
|
-
|
86
|
-
def variance_population(m=nil) # :nodoc:
|
87
|
-
check_type :numeric
|
88
|
-
m||=mean
|
89
|
-
gsl.nil? ? nil : gsl.variance_with_fixed_mean(m)
|
90
|
-
end
|
91
|
-
def standard_deviation_population(m=nil) # :nodoc:
|
92
|
-
check_type :numeric
|
93
|
-
m||=mean
|
94
|
-
gsl.nil? ? nil : gsl.sd_with_fixed_mean(m)
|
95
|
-
end
|
96
|
-
def skew # :nodoc:
|
97
|
-
check_type :numeric
|
98
|
-
gsl.nil? ? nil : gsl.skew
|
99
|
-
end
|
100
|
-
def kurtosis # :nodoc:
|
101
|
-
check_type :numeric
|
102
|
-
gsl.nil? ? nil : gsl.kurtosis
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
data/test/fixtures/test_csv.csv
DELETED
data/test/fixtures/test_xls.xls
DELETED
Binary file
|
data/test/test_csv.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'helpers_tests.rb'
|
2
|
-
|
3
|
-
class StatsampleCSVTestCase < Minitest::Test
|
4
|
-
def setup
|
5
|
-
@ds = Statsample::CSV.read('test/fixtures/test_csv.csv')
|
6
|
-
end
|
7
|
-
|
8
|
-
def test_read
|
9
|
-
header = %w(id name age city a1)
|
10
|
-
data = {
|
11
|
-
'id' => [1, 2, 3, 4, 5, 6].to_vector(:numeric),
|
12
|
-
'name' => %w(Alex Claude Peter Franz George Fernand).to_vector(:object),
|
13
|
-
'age' => [20, 23, 25, 27, 5.5, nil].to_vector(:numeric),
|
14
|
-
'city' => ['New York', 'London', 'London', 'Paris', 'Tome', nil].to_vector(:object),
|
15
|
-
'a1' => ['a,b', 'b,c', 'a', nil, 'a,b,c', nil].to_vector(:object)
|
16
|
-
}
|
17
|
-
|
18
|
-
ds_exp = Statsample::Dataset.new(data, header)
|
19
|
-
|
20
|
-
assert_equal(6, @ds.cases)
|
21
|
-
assert_equal(header, @ds.fields)
|
22
|
-
|
23
|
-
ds_exp.fields.each do |f|
|
24
|
-
assert_equal(ds_exp[f], @ds[f])
|
25
|
-
end
|
26
|
-
|
27
|
-
assert_equal(ds_exp, @ds)
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_nil
|
31
|
-
assert_equal(nil, @ds['age'][5])
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_repeated
|
35
|
-
ds = Statsample::CSV.read('test/fixtures/repeated_fields.csv')
|
36
|
-
assert_equal(%w(id name_1 age_1 city a1 name_2 age_2), ds.fields)
|
37
|
-
age = [3, 4, 5, 6, nil, 8].to_vector(:numeric)
|
38
|
-
assert_equal(age, ds['age_2'])
|
39
|
-
end
|
40
|
-
|
41
|
-
# Testing fix for SciRuby/statsample#19.
|
42
|
-
def test_accept_scientific_notation_as_float
|
43
|
-
ds = Statsample::CSV.read('test/fixtures/scientific_notation.csv')
|
44
|
-
assert_equal(%w(x y), ds.fields)
|
45
|
-
y = [9.629587310436753e+127, 1.9341543147883677e+129, 3.88485279048245e+130]
|
46
|
-
y.zip(ds['y']).each do |y_expected, y_ds|
|
47
|
-
assert_in_delta(y_expected, y_ds)
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_write
|
53
|
-
filename = Tempfile.new('afile')
|
54
|
-
Statsample::CSV.write(@ds, filename.path)
|
55
|
-
ds2 = Statsample::CSV.read(filename.path)
|
56
|
-
i = 0
|
57
|
-
|
58
|
-
ds2.each_array do |row|
|
59
|
-
assert_equal(@ds.case_as_array(i), row)
|
60
|
-
i += 1
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|