statsample 0.3.4 → 0.4.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.
Files changed (49) hide show
  1. data/History.txt +8 -0
  2. data/Manifest.txt +20 -2
  3. data/data/crime.txt +47 -0
  4. data/data/test_binomial.csv +201 -0
  5. data/demo/distribution_t.rb +2 -2
  6. data/demo/regression.rb +2 -1
  7. data/lib/distribution.rb +8 -0
  8. data/lib/distribution/chisquare.rb +24 -0
  9. data/lib/distribution/f.rb +25 -0
  10. data/lib/distribution/normal.rb +25 -0
  11. data/lib/distribution/t.rb +22 -0
  12. data/lib/matrix_extension.rb +78 -0
  13. data/lib/statistics2.rb +531 -0
  14. data/lib/statsample.rb +12 -9
  15. data/lib/statsample/anova.rb +1 -5
  16. data/lib/statsample/bivariate.rb +24 -20
  17. data/lib/statsample/combination.rb +14 -4
  18. data/lib/statsample/converters.rb +17 -1
  19. data/lib/statsample/dataset.rb +66 -10
  20. data/lib/statsample/dominanceanalysis/bootstrap.rb +1 -3
  21. data/lib/statsample/graph/gdchart.rb +2 -3
  22. data/lib/statsample/graph/svggraph.rb +8 -4
  23. data/lib/statsample/mle.rb +137 -0
  24. data/lib/statsample/mle/logit.rb +95 -0
  25. data/lib/statsample/mle/normal.rb +83 -0
  26. data/lib/statsample/mle/probit.rb +93 -0
  27. data/lib/statsample/regression.rb +3 -1
  28. data/lib/statsample/regression/binomial.rb +65 -0
  29. data/lib/statsample/regression/binomial/logit.rb +13 -0
  30. data/lib/statsample/regression/binomial/probit.rb +13 -0
  31. data/lib/statsample/regression/multiple.rb +61 -58
  32. data/lib/statsample/regression/multiple/rubyengine.rb +1 -1
  33. data/lib/statsample/srs.rb +5 -5
  34. data/lib/statsample/vector.rb +129 -59
  35. data/test/test_anova.rb +0 -5
  36. data/test/test_dataset.rb +13 -1
  37. data/test/test_distribution.rb +57 -0
  38. data/test/test_gsl.rb +22 -0
  39. data/test/test_logit.rb +22 -0
  40. data/test/test_mle.rb +140 -0
  41. data/test/test_r.rb +9 -0
  42. data/test/test_regression.rb +12 -4
  43. data/test/test_srs.rb +0 -4
  44. data/test/test_stata.rb +11 -0
  45. data/test/test_statistics.rb +0 -15
  46. data/test/test_vector.rb +11 -0
  47. metadata +28 -4
  48. data/lib/statsample/chidistribution.rb +0 -39
  49. data/lib/statsample/regression/logit.rb +0 -35
data/History.txt CHANGED
@@ -1,3 +1,11 @@
1
+ === 0.4.0 / 2009-09-10
2
+ * New Distribution module, based on statistics2.rb by Shin-ichiro HARA. Replaces all instances of GSL distributions pdf and cdf calculations for native calculation.
3
+ * New Maximum Likehood Estimation for Logit, Probit and Normal Distribution using Von Tessin(2005) algorithm. See MLE class and subclasses for more information.
4
+ * New Binomial regression subclasses (Logit and Probit), usign MLE class
5
+ * Added tests for gsl, Distribution, MLE and Logit
6
+ * Bug fix on svggraph.rb. Added check_type for scale graphics
7
+ * Bug fix on gdchart. Replaced old Nominal, Ordinal and Scale for Vector
8
+
1
9
  === 0.3.4 / 2009-08-21
2
10
  * Works with statsample-optimization 2.0.0
3
11
  * Vector doesn't uses delegation. All methods are part of Vector
data/Manifest.txt CHANGED
@@ -3,7 +3,9 @@ LICENSE.txt
3
3
  Manifest.txt
4
4
  README.txt
5
5
  bin/statsample
6
+ data/crime.txt
6
7
  data/locale/es/LC_MESSAGES/statsample.mo
8
+ data/test_binomial.csv
7
9
  demo/benchmark.rb
8
10
  demo/chi-square.rb
9
11
  demo/crosstab.rb
@@ -19,11 +21,17 @@ demo/sample_test.csv
19
21
  demo/strata_proportion.rb
20
22
  demo/stratum.rb
21
23
  demo/t-student.rb
24
+ lib/distribution.rb
25
+ lib/distribution/chisquare.rb
26
+ lib/distribution/f.rb
27
+ lib/distribution/normal.rb
28
+ lib/distribution/t.rb
29
+ lib/matrix_extension.rb
22
30
  lib/spss.rb
31
+ lib/statistics2.rb
23
32
  lib/statsample.rb
24
33
  lib/statsample/anova.rb
25
34
  lib/statsample/bivariate.rb
26
- lib/statsample/chidistribution.rb
27
35
  lib/statsample/codification.rb
28
36
  lib/statsample/combination.rb
29
37
  lib/statsample/converters.rb
@@ -37,9 +45,15 @@ lib/statsample/graph/svggraph.rb
37
45
  lib/statsample/graph/svghistogram.rb
38
46
  lib/statsample/graph/svgscatterplot.rb
39
47
  lib/statsample/htmlreport.rb
48
+ lib/statsample/mle.rb
49
+ lib/statsample/mle/logit.rb
50
+ lib/statsample/mle/normal.rb
51
+ lib/statsample/mle/probit.rb
40
52
  lib/statsample/multiset.rb
41
53
  lib/statsample/regression.rb
42
- lib/statsample/regression/logit.rb
54
+ lib/statsample/regression/binomial.rb
55
+ lib/statsample/regression/binomial/logit.rb
56
+ lib/statsample/regression/binomial/probit.rb
43
57
  lib/statsample/regression/multiple.rb
44
58
  lib/statsample/regression/multiple/alglibengine.rb
45
59
  lib/statsample/regression/multiple/gslengine.rb
@@ -61,7 +75,11 @@ test/test_crosstab.rb
61
75
  test/test_csv.csv
62
76
  test/test_csv.rb
63
77
  test/test_dataset.rb
78
+ test/test_distribution.rb
64
79
  test/test_ggobi.rb
80
+ test/test_gsl.rb
81
+ test/test_logit.rb
82
+ test/test_mle.rb
65
83
  test/test_multiset.rb
66
84
  test/test_regression.rb
67
85
  test/test_reliability.rb
data/data/crime.txt ADDED
@@ -0,0 +1,47 @@
1
+ 79.1 151 1 9.1 58 56 510 950 33 301 108 41 394 261
2
+ 163.5 143 0 11.3 103 95 583 1012 13 102 96 36 557 194
3
+ 57.8 142 1 8.9 45 44 533 969 18 219 94 33 318 250
4
+ 196.9 136 0 12.1 149 141 577 994 157 80 102 39 673 167
5
+ 123.4 141 0 12.1 109 101 591 985 18 30 91 20 578 174
6
+ 68.2 121 0 11.0 118 115 547 964 25 44 84 29 689 126
7
+ 96.3 127 1 11.1 82 79 519 982 4 139 97 38 620 168
8
+ 155.5 131 1 10.9 115 109 542 969 50 179 79 35 472 206
9
+ 85.6 157 1 9.0 65 62 553 955 39 286 81 28 421 239
10
+ 70.5 140 0 11.8 71 68 632 1029 7 15 100 24 526 174
11
+ 167.4 124 0 10.5 121 116 580 966 101 106 77 35 657 170
12
+ 84.9 134 0 10.8 75 71 595 972 47 59 83 31 580 172
13
+ 51.1 128 0 11.3 67 60 624 972 28 10 77 25 507 206
14
+ 66.4 135 0 11.7 62 61 595 986 22 46 77 27 529 190
15
+ 79.8 152 1 8.7 57 53 530 986 30 72 92 43 405 264
16
+ 94.6 142 1 8.8 81 77 497 956 33 321 116 47 427 247
17
+ 53.9 143 0 11.0 66 63 537 977 10 6 114 35 487 166
18
+ 92.9 135 1 10.4 123 115 537 978 31 170 89 34 631 165
19
+ 75.0 130 0 11.6 128 128 536 934 51 24 78 34 627 135
20
+ 122.5 125 0 10.8 113 105 567 985 78 94 130 58 626 166
21
+ 74.2 126 0 10.8 74 67 602 984 34 12 102 33 557 195
22
+ 43.9 157 1 8.9 47 44 512 962 22 423 97 34 288 276
23
+ 121.6 132 0 9.6 87 83 564 953 43 92 83 32 513 227
24
+ 96.8 131 0 11.6 78 73 574 1038 7 36 142 42 540 176
25
+ 52.3 130 0 11.6 63 57 641 984 14 26 70 21 486 196
26
+ 199.3 131 0 12.1 160 143 631 1071 3 77 102 41 674 152
27
+ 34.2 135 0 10.9 69 71 540 965 6 4 80 22 564 139
28
+ 121.6 152 0 11.2 82 76 571 1018 10 79 103 28 537 215
29
+ 104.3 119 0 10.7 166 157 521 938 168 89 92 36 637 154
30
+ 69.6 166 1 8.9 58 54 521 973 46 254 72 26 396 237
31
+ 37.3 140 0 9.3 55 54 535 1045 6 20 135 40 453 200
32
+ 75.4 125 0 10.9 90 81 586 964 97 82 105 43 617 163
33
+ 107.2 147 1 10.4 63 64 560 972 23 95 76 24 462 233
34
+ 92.3 126 0 11.8 97 97 542 990 18 21 102 35 589 166
35
+ 65.3 123 0 10.2 97 87 526 948 113 76 124 50 572 158
36
+ 127.2 150 0 10.0 109 98 531 964 9 24 87 38 559 153
37
+ 83.1 177 1 8.7 58 56 638 974 24 349 76 28 382 254
38
+ 56.6 133 0 10.4 51 47 599 1024 7 40 99 27 425 225
39
+ 82.6 149 1 8.8 61 54 515 953 36 165 86 35 395 251
40
+ 115.1 145 1 10.4 82 74 560 981 96 126 88 31 488 228
41
+ 88.0 148 0 12.2 72 66 601 998 9 19 84 20 590 144
42
+ 54.2 141 0 10.9 56 54 523 968 4 2 107 37 489 170
43
+ 82.3 162 1 9.9 75 70 522 996 40 208 73 27 496 224
44
+ 103.0 136 0 12.1 95 96 574 1012 29 36 111 37 622 162
45
+ 45.5 139 1 8.8 46 41 480 968 19 49 135 53 457 249
46
+ 50.8 126 0 10.4 106 97 599 989 40 24 78 25 593 171
47
+ 84.9 130 0 12.1 90 91 623 1049 3 22 113 40 588 160
@@ -0,0 +1,201 @@
1
+ a,b,c,y
2
+ 0.751712137198122,-3.26835910896471,1.70092606756102,0.0
3
+ 0.554214068711979,-2.95659724374009,2.66368360383625,0.0
4
+ -1.85331644460541,-2.8293733798982,3.34679611669776,0.0
5
+ -2.88610159022917,-0.738982407138072,4.74970154250585,0.0
6
+ -2.60553098049408,0.561020310042032,5.48308397712906,0.0
7
+ -4.27353214430849,1.62383436799538,5.35813425193809,0.0
8
+ -4.77012590041537,1.22025583429631,6.41070111604149,0.0
9
+ -6.92314832885029,2.86547174912175,8.7318591921429,0.0
10
+ -7.56419504045061,4.94028695088613,8.94193466569898,0.0
11
+ -8.63093667936286,4.27420502079032,9.27002100933965,0.0
12
+ -8.99111149517962,5.10389362675139,11.7669513163404,0.0
13
+ -9.99057638012989,7.87484596043453,12.4794035020575,0.0
14
+ -10.3818782968703,8.84300238382604,13.7498993372395,0.0
15
+ -11.0476824276485,9.44613324059569,13.502502696779,0.0
16
+ -12.4344241411336,9.7051587072806,15.122117356301,0.0
17
+ -13.6272942288038,10.419034297173,16.3289942692609,0.0
18
+ -15.6202224973741,11.3788332186947,17.7367653402519,0.0
19
+ -16.2922390869162,13.1516565107205,18.6939344625842,0.0
20
+ -16.7159137753851,14.9076297530125,18.0246863680123,0.0
21
+ -17.9501251836104,15.8533651031786,20.6826094110231,0.0
22
+ -18.9898843433331,15.4331557188719,20.9101142300728,0.0
23
+ -19.9085085832061,16.8542366574895,22.0721145894251,0.0
24
+ -21.1466526906367,18.6785324946036,23.4977598550022,0.0
25
+ -21.3675743976537,18.3208056358668,23.9121114020162,0.0
26
+ -22.131396135351,20.7616214854992,24.1683442928502,0.0
27
+ -23.1636319405886,21.1293492055766,25.2695476916398,0.0
28
+ -24.1360762823224,21.7035705688561,27.9161820459799,0.0
29
+ -25.3860721945057,23.3588003206916,27.8755285811136,0.0
30
+ -27.2546274134222,24.9201403553661,28.9810564843169,0.0
31
+ -28.84506179655,25.1681854417924,29.6749936376452,0.0
32
+ -29.5648703289208,26.3989365511582,30.3290447782847,0.0
33
+ -30.9473334996246,26.9014594846656,32.5460486188393,0.0
34
+ -30.6333205969831,27.9838524246205,32.63981307435,0.0
35
+ -31.1288464401156,28.0475385515748,34.4913247020856,0.0
36
+ -32.9192755199859,30.8664195945179,35.0830004548623,0.0
37
+ -33.5126863006676,31.7135111883763,35.963262553823,0.0
38
+ -35.0626135760564,31.0828516323826,36.6124285861271,0.0
39
+ -36.9524020008844,33.9722904006922,37.1501952879747,0.0
40
+ -36.8859458347289,34.1203333509726,38.5388292299586,0.0
41
+ -38.3029057124175,34.3054755372445,40.9141143587977,0.0
42
+ -38.4946443648172,35.0506904211858,40.2609817417396,0.0
43
+ -39.3511324722213,36.8560827180564,41.727133714198,0.0
44
+ -41.7530250817957,37.750760484498,43.8282650147001,0.0
45
+ -42.3509555518331,39.6673203525628,44.870018186039,0.0
46
+ -42.244528415626,39.0788755186789,45.7949681462311,0.0
47
+ -43.4340872344621,41.1905511155583,45.845002676574,0.0
48
+ -45.6641407465385,42.0427797845611,46.7401996025804,0.0
49
+ -46.3384022695138,42.4548123590202,47.6088880049696,0.0
50
+ -47.2110032014801,43.9466417934236,49.2425272385793,0.0
51
+ -48.5809364095671,45.2438778157098,49.7183364732398,0.0
52
+ -48.8367941243197,45.8093002387181,51.8176699160374,0.0
53
+ -49.3632780402121,47.2173660517208,51.910626136845,0.0
54
+ -51.3304857529218,48.2292571877905,53.890768221757,0.0
55
+ -52.6713212093626,48.0055890605259,54.2008024542977,0.0
56
+ -53.0492822384067,50.9227140239038,55.8288448459473,0.0
57
+ -53.5475407502719,50.399466736719,56.6653737429534,0.0
58
+ -54.9713103390392,52.2174375936081,57.5892087088816,0.0
59
+ -55.3824555656592,52.1624080567189,58.9048271122945,0.0
60
+ -57.2392061954268,53.0027225338458,59.7821645733191,0.0
61
+ -58.9104229152484,54.9892539015416,60.4219388424604,0.0
62
+ -58.1824120199409,56.3542717685635,61.2574760633137,0.0
63
+ -60.341564759061,56.7219808335487,61.0889655818828,0.0
64
+ -61.7134385451754,58.6296683714548,63.962361122351,0.0
65
+ -61.4485849309236,59.2722211731019,64.3931122256424,0.0
66
+ -63.0320403297596,60.7473007790999,64.4546114078189,0.0
67
+ -64.1041544802386,61.8740389113319,65.9649824945026,0.0
68
+ -65.4439008347463,62.1787709650214,67.730652575126,0.0
69
+ -65.3433374939793,63.9649079050439,67.2579323919331,0.0
70
+ -66.1146018531461,64.8632381781096,69.639884237254,0.0
71
+ -68.447747797377,65.4474036538936,69.6078430641903,0.0
72
+ -69.294418370038,65.4181483428477,70.0720760179831,0.0
73
+ -70.2849681665589,66.6959106050402,71.7102828712744,0.0
74
+ -70.4280941800939,67.6086197232511,72.3531894807932,1.0
75
+ -71.4902330755333,68.6959578032103,73.2224551274211,0.0
76
+ -72.0927102365517,69.6523144077888,74.0072309103283,0.0
77
+ -73.8239369250543,70.9727748471512,75.0623744862556,0.0
78
+ -74.0048051089996,72.4351875425075,76.9734643262443,0.0
79
+ -75.3894569624969,73.2005662031078,78.2395878278339,0.0
80
+ -77.2087700153069,73.873044622658,79.2174499824634,1.0
81
+ -78.3312007339737,74.3177101419062,80.4500892602852,0.0
82
+ -78.0152851918014,76.0879642141581,81.7807815886821,1.0
83
+ -79.6348564839424,76.2685721204187,82.516078707618,0.0
84
+ -81.9637989522169,77.0024986767795,82.4661448054153,0.0
85
+ -81.7384252154184,79.6668712051742,84.6703671298337,0.0
86
+ -83.6602393343142,80.4913108235325,85.1069139287146,0.0
87
+ -84.5817566138972,80.0267527066757,85.7126502390058,0.0
88
+ -84.1500643836875,82.9742935504215,87.7889543910899,0.0
89
+ -85.4066570769733,82.3347246270609,87.2294546291805,0.0
90
+ -87.7637024688064,83.3797423673815,88.7428383996369,1.0
91
+ -87.8532422216585,84.5508112461818,90.4419761299396,1.0
92
+ -89.4596482634063,86.7455889667711,90.0173299461518,0.0
93
+ -90.0512708441363,87.7184551425266,92.6086387957092,0.0
94
+ -91.7774688537336,88.3362578318951,92.5323490472281,0.0
95
+ -91.8941758249984,89.1756154247095,93.1997545484098,0.0
96
+ -93.6063748804845,89.6466643235472,95.9725910658342,0.0
97
+ -94.0398325903283,90.3812804437975,96.7702387180417,0.0
98
+ -94.8766180342569,91.4799550730711,97.2352819068861,1.0
99
+ -96.6522324427766,93.3217737988283,97.4817099617913,1.0
100
+ -96.2874457012073,93.6988909891918,98.8166711820106,0.0
101
+ -97.7197245583556,95.1054536364693,100.672788663657,0.0
102
+ -98.1481566037241,95.1218250594043,100.732200143903,0.0
103
+ -99.2071669041095,96.2150468128895,101.714216717689,0.0
104
+ -100.936418858708,98.4045788153991,102.613459593007,1.0
105
+ -102.443560747664,99.9196460296025,103.024089431854,1.0
106
+ -103.253024963442,100.800612294368,104.827681828628,1.0
107
+ -103.749612770423,101.647413918771,105.735965604858,1.0
108
+ -104.328852482254,101.52632439617,106.261555245069,1.0
109
+ -106.909854948268,103.417639882281,107.655384160196,0.0
110
+ -107.146277874964,103.735504363015,109.010106082004,1.0
111
+ -108.299680591253,105.221040236174,109.433289426765,1.0
112
+ -108.483982549154,106.450953357466,110.204651921964,1.0
113
+ -109.852652647883,107.528286824546,111.038226237901,1.0
114
+ -110.908323481598,107.109110976433,113.280776112873,1.0
115
+ -112.467924011291,108.685764539417,113.830693757837,1.0
116
+ -113.205608139008,110.215691301935,114.433169300046,0.0
117
+ -114.088065910725,111.855183307649,115.490962636794,1.0
118
+ -114.932088811468,112.821293025765,116.840371472296,1.0
119
+ -116.346270551874,112.158706089612,117.351225094843,0.0
120
+ -117.586523469426,113.660859727683,119.786169957249,0.0
121
+ -117.399020777901,115.140026386953,119.538050647704,0.0
122
+ -119.742251706502,116.297893641214,121.055886377645,1.0
123
+ -120.811568959087,116.442419636884,122.285416410297,1.0
124
+ -121.87197183902,117.772559468586,123.134175983163,0.0
125
+ -121.203532711179,118.217415486896,124.033131679149,1.0
126
+ -122.799770233652,119.066944773458,125.957266439052,0.0
127
+ -123.25939666012,121.092648631783,126.957392689029,1.0
128
+ -124.665594116895,122.943504248815,126.726922729708,1.0
129
+ -126.45629792163,123.680027227716,128.578446920242,1.0
130
+ -126.478395127934,124.860787507164,129.382354701582,1.0
131
+ -128.287481953834,124.904366629726,130.857704333381,1.0
132
+ -129.634518688906,126.002157605703,130.664679201595,1.0
133
+ -130.832869120258,126.312676682549,131.028091005298,1.0
134
+ -131.824704198069,128.491040094009,132.438881937649,1.0
135
+ -131.027748413386,128.666245091681,134.386819143277,1.0
136
+ -133.251129013031,129.041770903105,135.442572078667,0.0
137
+ -134.69199358524,131.797330031224,135.990306488139,1.0
138
+ -134.269836322383,131.114035752663,137.455991445092,1.0
139
+ -136.322562482609,133.458573512031,137.051219239798,1.0
140
+ -137.181797709245,134.690639765394,139.80399233003,1.0
141
+ -138.996622047529,135.735702581706,140.012525838337,1.0
142
+ -139.215574081352,135.215412440418,141.384571880875,1.0
143
+ -140.25643517594,136.693217029473,141.619094359002,1.0
144
+ -141.091696435808,138.544186252854,143.447467807219,1.0
145
+ -141.615279226692,139.247015471284,143.781551942357,1.0
146
+ -143.738916186876,140.442376021513,145.690446407267,1.0
147
+ -143.406661315583,141.611755086021,146.834954933569,1.0
148
+ -145.539994351071,141.864759154179,146.821868669993,1.0
149
+ -146.759792237469,143.72389809576,147.648189754648,1.0
150
+ -147.742745321685,143.773042536024,148.335412957969,1.0
151
+ -147.827110918347,144.891157822512,150.991195838727,1.0
152
+ -149.385928352478,146.506476517532,151.284254745032,1.0
153
+ -150.977776481931,146.021859562023,152.768419217875,1.0
154
+ -150.312752816396,148.730155452661,152.038272157343,1.0
155
+ -151.558966920835,148.800062079608,153.169105510546,1.0
156
+ -152.600091618579,150.820711027947,154.708689228766,1.0
157
+ -153.408136649531,151.844749166301,156.485789011581,1.0
158
+ -155.851442988913,152.727616801779,157.051864933563,1.0
159
+ -155.804122660613,153.080067542298,157.928538460402,1.0
160
+ -157.073427576551,153.343498427848,158.067904946476,1.0
161
+ -157.107508909122,154.26235452322,160.34811507316,1.0
162
+ -159.484841744779,155.071935569765,161.331016311668,1.0
163
+ -160.494393486944,156.832393661499,162.766796789861,1.0
164
+ -160.993630097021,157.641448785465,162.16966187911,1.0
165
+ -162.552759845799,159.539687734098,163.085996347117,1.0
166
+ -163.564091719115,159.348960279159,164.704726412269,1.0
167
+ -163.726283737347,161.928264713823,165.777638968284,1.0
168
+ -165.875733565084,162.238166456333,167.748146433357,1.0
169
+ -166.396130106934,163.168469688741,167.777541018587,1.0
170
+ -166.362936492002,164.060990842406,168.793540054343,1.0
171
+ -167.190830641697,164.69633527615,169.716276093277,1.0
172
+ -169.856337102559,165.948746195011,171.767907484416,1.0
173
+ -170.437574285639,166.585793448766,172.423441930238,1.0
174
+ -171.364589341033,167.713387609531,172.424258150602,1.0
175
+ -171.719858914268,168.568258270241,174.186728478313,1.0
176
+ -172.222432925774,169.341495037779,175.014592418557,1.0
177
+ -174.925024864504,170.009200154178,175.823166747739,1.0
178
+ -174.440609108192,172.585679891303,177.497935948773,1.0
179
+ -175.685134632762,172.597439708769,178.865842811381,1.0
180
+ -177.037735766697,174.337033018417,178.526154196112,1.0
181
+ -177.695754636999,175.158079880788,179.090845324338,1.0
182
+ -178.530965125958,175.998360662267,180.756244303945,1.0
183
+ -179.33859605694,177.055963520977,182.537104759468,1.0
184
+ -181.051026538749,178.749994896864,182.511752447157,1.0
185
+ -181.910324655635,178.191126997934,183.205490333945,1.0
186
+ -182.658814367512,179.821227820741,184.077256331919,1.0
187
+ -184.92643232869,181.744602320009,185.895789796461,1.0
188
+ -185.336918062898,181.363095955327,186.129937394056,1.0
189
+ -185.267288986526,182.500514904395,188.252778726315,1.0
190
+ -186.872953708712,184.965877299035,188.828219832583,1.0
191
+ -188.918306879815,185.051974487609,190.899813628421,1.0
192
+ -189.763521615511,185.68824128269,190.220429056165,1.0
193
+ -190.644174012638,187.750343044182,191.493983126918,1.0
194
+ -190.321219894606,187.817497818665,193.40572238254,1.0
195
+ -192.79354360347,188.86697228881,193.159805548127,1.0
196
+ -192.025564246072,189.147494777077,194.034017243282,1.0
197
+ -193.32579637306,190.629543307974,195.316361684183,1.0
198
+ -194.09803396593,192.184663556046,196.170525930209,1.0
199
+ -196.951286736902,192.950569139836,198.865411666979,1.0
200
+ -197.273285018295,193.455170048879,199.984457526702,1.0
201
+ -197.367054178611,194.765784862729,199.831724804912,1.0
@@ -71,8 +71,8 @@ Gnuplot.open do |gp|
71
71
  xxt.push(t)
72
72
  prev+=y
73
73
  xy.push(prev.to_f/tests)
74
- xt.push(GSL::Cdf.tdist_P(t, ss-1))
75
- xz.push(GSL::Cdf.gaussian_P(z))
74
+ xt.push(Distribution::T.cdf(t, ss-1))
75
+ xz.push(Distribution::Normal.cdf(z))
76
76
 
77
77
  }
78
78
  plot.data << Gnuplot::DataSet.new( [xxt,xy] ) do |ds|
data/demo/regression.rb CHANGED
@@ -32,6 +32,7 @@ else
32
32
 
33
33
 
34
34
  end
35
+
35
36
  ds.update_valid_data
36
37
 
37
38
  if !File.exists? "regression.dab"
@@ -39,7 +40,7 @@ if !File.exists? "regression.dab"
39
40
  else
40
41
  da=Statsample.load("regression.dab")
41
42
  end
42
- times=1
43
+ times=20
43
44
  if(true)
44
45
  Benchmark.bm(7) do |x|
45
46
  if HAS_GSL
@@ -0,0 +1,8 @@
1
+ require 'statistics2'
2
+ module Distribution
3
+ autoload(:ChiSquare, 'distribution/chisquare')
4
+ autoload(:T, 'distribution/t')
5
+ autoload(:F, 'distribution/f')
6
+ autoload(:Normal, 'distribution/normal')
7
+
8
+ end
@@ -0,0 +1,24 @@
1
+ module Distribution
2
+ # Calculate cdf and inverse cdf for Chi Square Distribution.
3
+ #
4
+ # Based on Babatunde, Iyiola & Eni () :
5
+ # "A Numerical Procedure for Computing Chi-Square Percentage Points"
6
+ #
7
+ module ChiSquare
8
+ class << self
9
+ # Return the P-value of the corresponding integral with
10
+ # k degrees of freedom
11
+ def p_value(pr,k)
12
+ Statistics2.pchi2X_(k, pr)
13
+ end
14
+ # Chi-square cumulative distribution function (cdf).
15
+ #
16
+ # Returns the integral of Chi-squared distribution
17
+ # with k degrees of freedom over [0, x]
18
+ #
19
+ def cdf(x,k)
20
+ Statistics2.chi2dist(k,x)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,25 @@
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.pfdist(k1,k2, pr)
12
+ end
13
+ # F cumulative distribution function (cdf).
14
+ #
15
+ # Returns the integral of F-distribution
16
+ # with k1 and k2 degrees of freedom
17
+ # over [0, x].
18
+ # Distribution::F.cdf(20,3,2)
19
+ #
20
+ def cdf(x, k1, k2)
21
+ Statistics2.fdist(k1, k2,x)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ module Distribution
2
+ # Calculate cdf and inverse cdf for Normal Distribution.
3
+ # Uses Statistics2 module
4
+ module Normal
5
+ class << self
6
+ # Return the P-value of the corresponding integral
7
+ def p_value(pr)
8
+ Statistics2.pnormaldist(pr)
9
+ end
10
+ # Normal cumulative distribution function (cdf).
11
+ #
12
+ # Returns the integral of normal distribution
13
+ # over (-Infty, x].
14
+ #
15
+ def cdf(x)
16
+ Statistics2.normaldist(x)
17
+ end
18
+ # Normal probability density function (pdf)
19
+ # With x=0 and sigma=1
20
+ def pdf(x)
21
+ (1.0/Math::sqrt(2*Math::PI))*Math::exp(-(x**2/2.0))
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,22 @@
1
+ module Distribution
2
+
3
+ # Calculate cdf and inverse cdf for T Distribution.
4
+ # Uses Statistics2 Module.
5
+ module T
6
+ class << self
7
+ # Return the P-value of the corresponding integral with
8
+ # k degrees of freedom
9
+ def p_value(pr,k)
10
+ Statistics2.ptdist(k, pr)
11
+ end
12
+ # T cumulative distribution function (cdf).
13
+ #
14
+ # Returns the integral of t-distribution
15
+ # with n degrees of freedom over (-Infty, x].
16
+ #
17
+ def cdf(x,k)
18
+ Statistics2.tdist(k, x)
19
+ end
20
+ end
21
+ end
22
+ end