File: statistics.n

package info (click to toggle)
tcllib 2.0%2Bdfsg-4
  • links: PTS
  • area: main
  • in suites: trixie
  • size: 83,572 kB
  • sloc: tcl: 306,798; ansic: 14,272; sh: 3,035; xml: 1,766; yacc: 1,157; pascal: 881; makefile: 124; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (2911 lines) | stat: -rw-r--r-- 79,215 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
'\"
'\" Generated from file 'statistics\&.man' by tcllib/doctools with format 'nroff'
'\"
.TH "math::statistics" n 1\&.6\&.1 tcllib "Tcl Math Library"
.\" The -*- nroff -*- definitions below are for supplemental macros used
.\" in Tcl/Tk manual entries.
.\"
.\" .AP type name in/out ?indent?
.\"	Start paragraph describing an argument to a library procedure.
.\"	type is type of argument (int, etc.), in/out is either "in", "out",
.\"	or "in/out" to describe whether procedure reads or modifies arg,
.\"	and indent is equivalent to second arg of .IP (shouldn't ever be
.\"	needed;  use .AS below instead)
.\"
.\" .AS ?type? ?name?
.\"	Give maximum sizes of arguments for setting tab stops.  Type and
.\"	name are examples of largest possible arguments that will be passed
.\"	to .AP later.  If args are omitted, default tab stops are used.
.\"
.\" .BS
.\"	Start box enclosure.  From here until next .BE, everything will be
.\"	enclosed in one large box.
.\"
.\" .BE
.\"	End of box enclosure.
.\"
.\" .CS
.\"	Begin code excerpt.
.\"
.\" .CE
.\"	End code excerpt.
.\"
.\" .VS ?version? ?br?
.\"	Begin vertical sidebar, for use in marking newly-changed parts
.\"	of man pages.  The first argument is ignored and used for recording
.\"	the version when the .VS was added, so that the sidebars can be
.\"	found and removed when they reach a certain age.  If another argument
.\"	is present, then a line break is forced before starting the sidebar.
.\"
.\" .VE
.\"	End of vertical sidebar.
.\"
.\" .DS
.\"	Begin an indented unfilled display.
.\"
.\" .DE
.\"	End of indented unfilled display.
.\"
.\" .SO ?manpage?
.\"	Start of list of standard options for a Tk widget. The manpage
.\"	argument defines where to look up the standard options; if
.\"	omitted, defaults to "options". The options follow on successive
.\"	lines, in three columns separated by tabs.
.\"
.\" .SE
.\"	End of list of standard options for a Tk widget.
.\"
.\" .OP cmdName dbName dbClass
.\"	Start of description of a specific option.  cmdName gives the
.\"	option's name as specified in the class command, dbName gives
.\"	the option's name in the option database, and dbClass gives
.\"	the option's class in the option database.
.\"
.\" .UL arg1 arg2
.\"	Print arg1 underlined, then print arg2 normally.
.\"
.\" .QW arg1 ?arg2?
.\"	Print arg1 in quotes, then arg2 normally (for trailing punctuation).
.\"
.\" .PQ arg1 ?arg2?
.\"	Print an open parenthesis, arg1 in quotes, then arg2 normally
.\"	(for trailing punctuation) and then a closing parenthesis.
.\"
.\"	# Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
.if t .wh -1.3i ^B
.nr ^l \n(.l
.ad b
.\"	# Start an argument description
.de AP
.ie !"\\$4"" .TP \\$4
.el \{\
.   ie !"\\$2"" .TP \\n()Cu
.   el          .TP 15
.\}
.ta \\n()Au \\n()Bu
.ie !"\\$3"" \{\
\&\\$1 \\fI\\$2\\fP (\\$3)
.\".b
.\}
.el \{\
.br
.ie !"\\$2"" \{\
\&\\$1	\\fI\\$2\\fP
.\}
.el \{\
\&\\fI\\$1\\fP
.\}
.\}
..
.\"	# define tabbing values for .AP
.de AS
.nr )A 10n
.if !"\\$1"" .nr )A \\w'\\$1'u+3n
.nr )B \\n()Au+15n
.\"
.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
.nr )C \\n()Bu+\\w'(in/out)'u+2n
..
.AS Tcl_Interp Tcl_CreateInterp in/out
.\"	# BS - start boxed text
.\"	# ^y = starting y location
.\"	# ^b = 1
.de BS
.br
.mk ^y
.nr ^b 1u
.if n .nf
.if n .ti 0
.if n \l'\\n(.lu\(ul'
.if n .fi
..
.\"	# BE - end boxed text (draw box now)
.de BE
.nf
.ti 0
.mk ^t
.ie n \l'\\n(^lu\(ul'
.el \{\
.\"	Draw four-sided box normally, but don't draw top of
.\"	box if the box started on an earlier page.
.ie !\\n(^b-1 \{\
\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
.\}
.el \}\
\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
.\}
.\}
.fi
.br
.nr ^b 0
..
.\"	# VS - start vertical sidebar
.\"	# ^Y = starting y location
.\"	# ^v = 1 (for troff;  for nroff this doesn't matter)
.de VS
.if !"\\$2"" .br
.mk ^Y
.ie n 'mc \s12\(br\s0
.el .nr ^v 1u
..
.\"	# VE - end of vertical sidebar
.de VE
.ie n 'mc
.el \{\
.ev 2
.nf
.ti 0
.mk ^t
\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
.sp -1
.fi
.ev
.\}
.nr ^v 0
..
.\"	# Special macro to handle page bottom:  finish off current
.\"	# box/sidebar if in box/sidebar mode, then invoked standard
.\"	# page bottom macro.
.de ^B
.ev 2
'ti 0
'nf
.mk ^t
.if \\n(^b \{\
.\"	Draw three-sided box if this is the box's first page,
.\"	draw two sides but no top otherwise.
.ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
.\}
.if \\n(^v \{\
.nr ^x \\n(^tu+1v-\\n(^Yu
\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
.\}
.bp
'fi
.ev
.if \\n(^b \{\
.mk ^y
.nr ^b 2
.\}
.if \\n(^v \{\
.mk ^Y
.\}
..
.\"	# DS - begin display
.de DS
.RS
.nf
.sp
..
.\"	# DE - end display
.de DE
.fi
.RE
.sp
..
.\"	# SO - start of list of standard options
.de SO
'ie '\\$1'' .ds So \\fBoptions\\fR
'el .ds So \\fB\\$1\\fR
.SH "STANDARD OPTIONS"
.LP
.nf
.ta 5.5c 11c
.ft B
..
.\"	# SE - end of list of standard options
.de SE
.fi
.ft R
.LP
See the \\*(So manual entry for details on the standard options.
..
.\"	# OP - start of full description for a single option
.de OP
.LP
.nf
.ta 4c
Command-Line Name:	\\fB\\$1\\fR
Database Name:	\\fB\\$2\\fR
Database Class:	\\fB\\$3\\fR
.fi
.IP
..
.\"	# CS - begin code excerpt
.de CS
.RS
.nf
.ta .25i .5i .75i 1i
..
.\"	# CE - end code excerpt
.de CE
.fi
.RE
..
.\"	# UL - underline word
.de UL
\\$1\l'|0\(ul'\\$2
..
.\"	# QW - apply quotation marks to word
.de QW
.ie '\\*(lq'"' ``\\$1''\\$2
.\"" fix emacs highlighting
.el \\*(lq\\$1\\*(rq\\$2
..
.\"	# PQ - apply parens and quotation marks to word
.de PQ
.ie '\\*(lq'"' (``\\$1''\\$2)\\$3
.\"" fix emacs highlighting
.el (\\*(lq\\$1\\*(rq\\$2)\\$3
..
.\"	# QR - quoted range
.de QR
.ie '\\*(lq'"' ``\\$1''\\-``\\$2''\\$3
.\"" fix emacs highlighting
.el \\*(lq\\$1\\*(rq\\-\\*(lq\\$2\\*(rq\\$3
..
.\"	# MT - "empty" string
.de MT
.QW ""
..
.BS
.SH NAME
math::statistics \- Basic statistical functions and procedures
.SH SYNOPSIS
package require \fBTcl 8\&.5 9\fR
.sp
package require \fBmath::statistics 1\&.6\&.1\fR
.sp
\fB::math::statistics::mean\fR \fIdata\fR
.sp
\fB::math::statistics::min\fR \fIdata\fR
.sp
\fB::math::statistics::max\fR \fIdata\fR
.sp
\fB::math::statistics::number\fR \fIdata\fR
.sp
\fB::math::statistics::stdev\fR \fIdata\fR
.sp
\fB::math::statistics::var\fR \fIdata\fR
.sp
\fB::math::statistics::pstdev\fR \fIdata\fR
.sp
\fB::math::statistics::pvar\fR \fIdata\fR
.sp
\fB::math::statistics::median\fR \fIdata\fR
.sp
\fB::math::statistics::basic-stats\fR \fIdata\fR
.sp
\fB::math::statistics::histogram\fR \fIlimits\fR \fIvalues\fR ?weights?
.sp
\fB::math::statistics::histogram-alt\fR \fIlimits\fR \fIvalues\fR ?weights?
.sp
\fB::math::statistics::corr\fR \fIdata1\fR \fIdata2\fR
.sp
\fB::math::statistics::interval-mean-stdev\fR \fIdata\fR \fIconfidence\fR
.sp
\fB::math::statistics::t-test-mean\fR \fIdata\fR \fIest_mean\fR \fIest_stdev\fR \fIalpha\fR
.sp
\fB::math::statistics::test-normal\fR \fIdata\fR \fIsignificance\fR
.sp
\fB::math::statistics::lillieforsFit\fR \fIdata\fR
.sp
\fB::math::statistics::test-Duckworth\fR \fIlist1\fR \fIlist2\fR \fIsignificance\fR
.sp
\fB::math::statistics::test-anova-F\fR \fIalpha\fR \fIargs\fR
.sp
\fB::math::statistics::test-Tukey-range\fR \fIalpha\fR \fIargs\fR
.sp
\fB::math::statistics::test-Dunnett\fR \fIalpha\fR \fIcontrol\fR \fIargs\fR
.sp
\fB::math::statistics::quantiles\fR \fIdata\fR \fIconfidence\fR
.sp
\fB::math::statistics::quantiles\fR \fIlimits\fR \fIcounts\fR \fIconfidence\fR
.sp
\fB::math::statistics::autocorr\fR \fIdata\fR
.sp
\fB::math::statistics::crosscorr\fR \fIdata1\fR \fIdata2\fR
.sp
\fB::math::statistics::mean-histogram-limits\fR \fImean\fR \fIstdev\fR \fInumber\fR
.sp
\fB::math::statistics::minmax-histogram-limits\fR \fImin\fR \fImax\fR \fInumber\fR
.sp
\fB::math::statistics::linear-model\fR \fIxdata\fR \fIydata\fR \fIintercept\fR
.sp
\fB::math::statistics::linear-residuals\fR \fIxdata\fR \fIydata\fR \fIintercept\fR
.sp
\fB::math::statistics::test-2x2\fR \fIn11\fR \fIn21\fR \fIn12\fR \fIn22\fR
.sp
\fB::math::statistics::print-2x2\fR \fIn11\fR \fIn21\fR \fIn12\fR \fIn22\fR
.sp
\fB::math::statistics::control-xbar\fR \fIdata\fR ?nsamples?
.sp
\fB::math::statistics::control-Rchart\fR \fIdata\fR ?nsamples?
.sp
\fB::math::statistics::test-xbar\fR \fIcontrol\fR \fIdata\fR
.sp
\fB::math::statistics::test-Rchart\fR \fIcontrol\fR \fIdata\fR
.sp
\fB::math::statistics::test-Kruskal-Wallis\fR \fIconfidence\fR \fIargs\fR
.sp
\fB::math::statistics::analyse-Kruskal-Wallis\fR \fIargs\fR
.sp
\fB::math::statistics::test-Levene\fR \fIgroups\fR
.sp
\fB::math::statistics::test-Brown-Forsythe\fR \fIgroups\fR
.sp
\fB::math::statistics::group-rank\fR \fIargs\fR
.sp
\fB::math::statistics::test-Wilcoxon\fR \fIsample_a\fR \fIsample_b\fR
.sp
\fB::math::statistics::spearman-rank\fR \fIsample_a\fR \fIsample_b\fR
.sp
\fB::math::statistics::spearman-rank-extended\fR \fIsample_a\fR \fIsample_b\fR
.sp
\fB::math::statistics::kernel-density\fR \fIdata\fR opt \fI-option value\fR \&.\&.\&.
.sp
\fB::math::statistics::bootstrap\fR \fIdata\fR \fIsampleSize\fR ?numberSamples?
.sp
\fB::math::statistics::wasserstein-distance\fR \fIprob1\fR \fIprob2\fR
.sp
\fB::math::statistics::kl-divergence\fR \fIprob1\fR \fIprob2\fR
.sp
\fB::math::statistics::logistic-model\fR \fIxdata\fR \fIydata\fR
.sp
\fB::math::statistics::logistic-probability\fR \fIcoeffs\fR \fIx\fR
.sp
\fB::math::statistics::tstat\fR \fIdof\fR ?alpha?
.sp
\fB::math::statistics::mv-wls\fR \fIweights_and_values\fR
.sp
\fB::math::statistics::mv-ols\fR \fIvalues\fR
.sp
\fB::math::statistics::pdf-normal\fR \fImean\fR \fIstdev\fR \fIvalue\fR
.sp
\fB::math::statistics::pdf-lognormal\fR \fImean\fR \fIstdev\fR \fIvalue\fR
.sp
\fB::math::statistics::pdf-exponential\fR \fImean\fR \fIvalue\fR
.sp
\fB::math::statistics::pdf-uniform\fR \fIxmin\fR \fIxmax\fR \fIvalue\fR
.sp
\fB::math::statistics::pdf-triangular\fR \fIxmin\fR \fIxmax\fR \fIvalue\fR
.sp
\fB::math::statistics::pdf-symmetric-triangular\fR \fIxmin\fR \fIxmax\fR \fIvalue\fR
.sp
\fB::math::statistics::pdf-gamma\fR \fIalpha\fR \fIbeta\fR \fIvalue\fR
.sp
\fB::math::statistics::pdf-poisson\fR \fImu\fR \fIk\fR
.sp
\fB::math::statistics::pdf-chisquare\fR \fIdf\fR \fIvalue\fR
.sp
\fB::math::statistics::pdf-student-t\fR \fIdf\fR \fIvalue\fR
.sp
\fB::math::statistics::pdf-gamma\fR \fIa\fR \fIb\fR \fIvalue\fR
.sp
\fB::math::statistics::pdf-beta\fR \fIa\fR \fIb\fR \fIvalue\fR
.sp
\fB::math::statistics::pdf-weibull\fR \fIscale\fR \fIshape\fR \fIvalue\fR
.sp
\fB::math::statistics::pdf-gumbel\fR \fIlocation\fR \fIscale\fR \fIvalue\fR
.sp
\fB::math::statistics::pdf-pareto\fR \fIscale\fR \fIshape\fR \fIvalue\fR
.sp
\fB::math::statistics::pdf-cauchy\fR \fIlocation\fR \fIscale\fR \fIvalue\fR
.sp
\fB::math::statistics::pdf-laplace\fR \fIlocation\fR \fIscale\fR \fIvalue\fR
.sp
\fB::math::statistics::pdf-kumaraswamy\fR \fIa\fR \fIb\fR \fIvalue\fR
.sp
\fB::math::statistics::pdf-negative-binomial\fR \fIr\fR \fIp\fR \fIvalue\fR
.sp
\fB::math::statistics::cdf-normal\fR \fImean\fR \fIstdev\fR \fIvalue\fR
.sp
\fB::math::statistics::cdf-lognormal\fR \fImean\fR \fIstdev\fR \fIvalue\fR
.sp
\fB::math::statistics::cdf-exponential\fR \fImean\fR \fIvalue\fR
.sp
\fB::math::statistics::cdf-uniform\fR \fIxmin\fR \fIxmax\fR \fIvalue\fR
.sp
\fB::math::statistics::cdf-triangular\fR \fIxmin\fR \fIxmax\fR \fIvalue\fR
.sp
\fB::math::statistics::cdf-symmetric-triangular\fR \fIxmin\fR \fIxmax\fR \fIvalue\fR
.sp
\fB::math::statistics::cdf-students-t\fR \fIdegrees\fR \fIvalue\fR
.sp
\fB::math::statistics::cdf-gamma\fR \fIalpha\fR \fIbeta\fR \fIvalue\fR
.sp
\fB::math::statistics::cdf-poisson\fR \fImu\fR \fIk\fR
.sp
\fB::math::statistics::cdf-beta\fR \fIa\fR \fIb\fR \fIvalue\fR
.sp
\fB::math::statistics::cdf-weibull\fR \fIscale\fR \fIshape\fR \fIvalue\fR
.sp
\fB::math::statistics::cdf-gumbel\fR \fIlocation\fR \fIscale\fR \fIvalue\fR
.sp
\fB::math::statistics::cdf-pareto\fR \fIscale\fR \fIshape\fR \fIvalue\fR
.sp
\fB::math::statistics::cdf-cauchy\fR \fIlocation\fR \fIscale\fR \fIvalue\fR
.sp
\fB::math::statistics::cdf-F\fR \fInf1\fR \fInf2\fR \fIvalue\fR
.sp
\fB::math::statistics::cdf-laplace\fR \fIlocation\fR \fIscale\fR \fIvalue\fR
.sp
\fB::math::statistics::cdf-kumaraswamy\fR \fIa\fR \fIb\fR \fIvalue\fR
.sp
\fB::math::statistics::cdf-negative-binomial\fR \fIr\fR \fIp\fR \fIvalue\fR
.sp
\fB::math::statistics::empirical-distribution\fR \fIvalues\fR
.sp
\fB::math::statistics::random-normal\fR \fImean\fR \fIstdev\fR \fInumber\fR
.sp
\fB::math::statistics::random-lognormal\fR \fImean\fR \fIstdev\fR \fInumber\fR
.sp
\fB::math::statistics::random-exponential\fR \fImean\fR \fInumber\fR
.sp
\fB::math::statistics::random-uniform\fR \fIxmin\fR \fIxmax\fR \fInumber\fR
.sp
\fB::math::statistics::random-triangular\fR \fIxmin\fR \fIxmax\fR \fInumber\fR
.sp
\fB::math::statistics::random-symmetric-triangular\fR \fIxmin\fR \fIxmax\fR \fInumber\fR
.sp
\fB::math::statistics::random-gamma\fR \fIalpha\fR \fIbeta\fR \fInumber\fR
.sp
\fB::math::statistics::random-poisson\fR \fImu\fR \fInumber\fR
.sp
\fB::math::statistics::random-chisquare\fR \fIdf\fR \fInumber\fR
.sp
\fB::math::statistics::random-student-t\fR \fIdf\fR \fInumber\fR
.sp
\fB::math::statistics::random-beta\fR \fIa\fR \fIb\fR \fInumber\fR
.sp
\fB::math::statistics::random-weibull\fR \fIscale\fR \fIshape\fR \fInumber\fR
.sp
\fB::math::statistics::random-gumbel\fR \fIlocation\fR \fIscale\fR \fInumber\fR
.sp
\fB::math::statistics::random-pareto\fR \fIscale\fR \fIshape\fR \fInumber\fR
.sp
\fB::math::statistics::random-cauchy\fR \fIlocation\fR \fIscale\fR \fInumber\fR
.sp
\fB::math::statistics::random-laplace\fR \fIlocation\fR \fIscale\fR \fInumber\fR
.sp
\fB::math::statistics::random-kumaraswamy\fR \fIa\fR \fIb\fR \fInumber\fR
.sp
\fB::math::statistics::random-negative-binomial\fR \fIr\fR \fIp\fR \fInumber\fR
.sp
\fB::math::statistics::histogram-uniform\fR \fIxmin\fR \fIxmax\fR \fIlimits\fR \fInumber\fR
.sp
\fB::math::statistics::incompleteGamma\fR \fIx\fR \fIp\fR ?tol?
.sp
\fB::math::statistics::incompleteBeta\fR \fIa\fR \fIb\fR \fIx\fR ?tol?
.sp
\fB::math::statistics::estimate-pareto\fR \fIvalues\fR
.sp
\fB::math::statistics::estimate-exponential\fR \fIvalues\fR
.sp
\fB::math::statistics::estimate-laplace\fR \fIvalues\fR
.sp
\fB::math::statistics::estimante-negative-binomial\fR \fIr\fR \fIvalues\fR
.sp
\fB::math::statistics::filter\fR \fIvarname\fR \fIdata\fR \fIexpression\fR
.sp
\fB::math::statistics::map\fR \fIvarname\fR \fIdata\fR \fIexpression\fR
.sp
\fB::math::statistics::samplescount\fR \fIvarname\fR \fIlist\fR \fIexpression\fR
.sp
\fB::math::statistics::subdivide\fR
.sp
\fB::math::statistics::plot-scale\fR \fIcanvas\fR \fIxmin\fR \fIxmax\fR \fIymin\fR \fIymax\fR
.sp
\fB::math::statistics::plot-xydata\fR \fIcanvas\fR \fIxdata\fR \fIydata\fR \fItag\fR
.sp
\fB::math::statistics::plot-xyline\fR \fIcanvas\fR \fIxdata\fR \fIydata\fR \fItag\fR
.sp
\fB::math::statistics::plot-tdata\fR \fIcanvas\fR \fItdata\fR \fItag\fR
.sp
\fB::math::statistics::plot-tline\fR \fIcanvas\fR \fItdata\fR \fItag\fR
.sp
\fB::math::statistics::plot-histogram\fR \fIcanvas\fR \fIcounts\fR \fIlimits\fR \fItag\fR
.sp
.BE
.SH DESCRIPTION
.PP
The \fBmath::statistics\fR package contains functions and procedures for
basic statistical data analysis, such as:
.IP \(bu
Descriptive statistical parameters (mean, minimum, maximum, standard
deviation)
.IP \(bu
Estimates of the distribution in the form of histograms and quantiles
.IP \(bu
Basic testing of hypotheses
.IP \(bu
Probability and cumulative density functions
.PP
It is meant to help in developing data analysis applications or doing
ad hoc data analysis, it is not in itself a full application, nor is it
intended to rival with full (non-)commercial statistical packages\&.
.PP
The purpose of this document is to describe the implemented procedures
and provide some examples of their usage\&. As there is ample literature
on the algorithms involved, we refer to relevant text books for more
explanations\&.
The package contains a fairly large number of public procedures\&. They
can be distinguished in three sets: general procedures, procedures
that deal with specific statistical distributions, list procedures to
select or transform data and simple plotting procedures (these require
Tk)\&.
\fINote:\fR The data that need to be analyzed are always contained in a
simple list\&. Missing values are represented as empty list elements\&.
\fINote:\fR With version 1\&.0\&.1 a mistake in the procs \fIpdf-lognormal\fR,
\fIcdf-lognormal\fR and \fIrandom-lognormal\fR has been corrected\&. In
previous versions the argument for the standard deviation was actually
used as if it was the variance\&.
.SH "GENERAL PROCEDURES"
The general statistical procedures are:
.TP
\fB::math::statistics::mean\fR \fIdata\fR
Determine the \fImean\fR value of the given list of data\&.
.RS
.TP
list \fIdata\fR
- List of data
.RE
.sp
.TP
\fB::math::statistics::min\fR \fIdata\fR
Determine the \fIminimum\fR value of the given list of data\&.
.RS
.TP
list \fIdata\fR
- List of data
.RE
.sp
.TP
\fB::math::statistics::max\fR \fIdata\fR
Determine the \fImaximum\fR value of the given list of data\&.
.RS
.TP
list \fIdata\fR
- List of data
.RE
.sp
.TP
\fB::math::statistics::number\fR \fIdata\fR
Determine the \fInumber\fR of non-missing data in the given list
.RS
.TP
list \fIdata\fR
- List of data
.RE
.sp
.TP
\fB::math::statistics::stdev\fR \fIdata\fR
Determine the \fIsample standard deviation\fR of the data in the
given list
.RS
.TP
list \fIdata\fR
- List of data
.RE
.sp
.TP
\fB::math::statistics::var\fR \fIdata\fR
Determine the \fIsample variance\fR of the data in the given list
.RS
.TP
list \fIdata\fR
- List of data
.RE
.sp
.TP
\fB::math::statistics::pstdev\fR \fIdata\fR
Determine the \fIpopulation standard deviation\fR of the data
in the given list
.RS
.TP
list \fIdata\fR
- List of data
.RE
.sp
.TP
\fB::math::statistics::pvar\fR \fIdata\fR
Determine the \fIpopulation variance\fR of the data in the
given list
.RS
.TP
list \fIdata\fR
- List of data
.RE
.sp
.TP
\fB::math::statistics::median\fR \fIdata\fR
Determine the \fImedian\fR of the data in the given list
(Note that this requires sorting the data, which may be a
costly operation)
.RS
.TP
list \fIdata\fR
- List of data
.RE
.sp
.TP
\fB::math::statistics::basic-stats\fR \fIdata\fR
Determine a list of all the descriptive parameters: mean, minimum,
maximum, number of data, sample standard deviation, sample variance,
population standard deviation and population variance\&.
.sp
(This routine is called whenever either or all of the basic statistical
parameters are required\&. Hence all calculations are done and the
relevant values are returned\&.)
.RS
.TP
list \fIdata\fR
- List of data
.RE
.sp
.TP
\fB::math::statistics::histogram\fR \fIlimits\fR \fIvalues\fR ?weights?
Determine histogram information for the given list of data\&. Returns a
list consisting of the number of values that fall into each interval\&.
(The first interval consists of all values lower than the first limit,
the last interval consists of all values greater than the last limit\&.
There is one more interval than there are limits\&.)
.sp
Optionally, you can use weights to influence the histogram\&.
.RS
.TP
list \fIlimits\fR
- List of upper limits (in ascending order) for the
intervals of the histogram\&.
.TP
list \fIvalues\fR
- List of data
.TP
list \fIweights\fR
- List of weights, one weight per value
.RE
.sp
.TP
\fB::math::statistics::histogram-alt\fR \fIlimits\fR \fIvalues\fR ?weights?
Alternative implementation of the histogram procedure: the open end of the intervals
is at the lower bound instead of the upper bound\&.
.RS
.TP
list \fIlimits\fR
- List of upper limits (in ascending order) for the
intervals of the histogram\&.
.TP
list \fIvalues\fR
- List of data
.TP
list \fIweights\fR
- List of weights, one weight per value
.RE
.sp
.TP
\fB::math::statistics::corr\fR \fIdata1\fR \fIdata2\fR
Determine the correlation coefficient between two sets of data\&.
.RS
.TP
list \fIdata1\fR
- First list of data
.TP
list \fIdata2\fR
- Second list of data
.RE
.sp
.TP
\fB::math::statistics::interval-mean-stdev\fR \fIdata\fR \fIconfidence\fR
Return the interval containing the mean value and one
containing the standard deviation with a certain
level of confidence (assuming a normal distribution)
.RS
.TP
list \fIdata\fR
- List of raw data values (small sample)
.TP
float \fIconfidence\fR
- Confidence level (0\&.95 or 0\&.99 for instance)
.RE
.sp
.TP
\fB::math::statistics::t-test-mean\fR \fIdata\fR \fIest_mean\fR \fIest_stdev\fR \fIalpha\fR
Test whether the mean value of a sample is in accordance with the
estimated normal distribution with a certain probability\&.
Returns 1 if the test succeeds or 0 if the mean is unlikely to fit
the given distribution\&.
.RS
.TP
list \fIdata\fR
- List of raw data values (small sample)
.TP
float \fIest_mean\fR
- Estimated mean of the distribution
.TP
float \fIest_stdev\fR
- Estimated stdev of the distribution
.TP
float \fIalpha\fR
- Probability level (0\&.95 or 0\&.99 for instance)
.RE
.sp
.TP
\fB::math::statistics::test-normal\fR \fIdata\fR \fIsignificance\fR
Test whether the given data follow a normal distribution
with a certain level of significance\&.
Returns 1 if the data are normally distributed within the level of
significance, returns 0 if not\&. The underlying test is the Lilliefors
test\&. Smaller values of the significance mean a stricter testing\&.
.RS
.TP
list \fIdata\fR
- List of raw data values
.TP
float \fIsignificance\fR
- Significance level (one of 0\&.01, 0\&.05, 0\&.10, 0\&.15 or 0\&.20)\&. For compatibility
reasons the values "1-significance", 0\&.80, 0\&.85, 0\&.90, 0\&.95 or 0\&.99 are also accepted\&.
.RE
.sp
Compatibility issue: the original implementation and documentation used the term "confidence" and used a value
1-significance (see ticket 2812473fff)\&. This has been corrected as of version 0\&.9\&.3\&.
.sp
.TP
\fB::math::statistics::lillieforsFit\fR \fIdata\fR
Returns the goodness of fit to a normal distribution according to
Lilliefors\&. The higher the number, the more likely the data are indeed
normally distributed\&. The test requires at least \fIfive\fR data
points\&.
.RS
.TP
list \fIdata\fR
- List of raw data values
.RE
.sp
.TP
\fB::math::statistics::test-Duckworth\fR \fIlist1\fR \fIlist2\fR \fIsignificance\fR
Determine if two data sets have the same median according to the Tukey-Duckworth test\&.
The procedure returns 0 if the medians are unequal, 1 if they are equal, -1 if the test can not
be conducted (the smallest value must be in a different set than the greatest value)\&.
#
# Arguments:
#     list1           Values in the first data set
#     list2           Values in the second data set
#     significance    Significance level (either 0\&.05, 0\&.01 or 0\&.001)
#
# Returns:
Test whether the given data follow a normal distribution
with a certain level of significance\&.
Returns 1 if the data are normally distributed within the level of
significance, returns 0 if not\&. The underlying test is the Lilliefors
test\&. Smaller values of the significance mean a stricter testing\&.
.RS
.TP
list \fIlist1\fR
- First list of data
.TP
list \fIlist2\fR
- Second list of data
.TP
float \fIsignificance\fR
- Significance level (either 0\&.05, 0\&.01 or 0\&.001)
.RE
.sp
.TP
\fB::math::statistics::test-anova-F\fR \fIalpha\fR \fIargs\fR
Determine if two or more groups with normally distributed data have the same means\&.
The procedure returns 0 if the means are likely unequal, 1 if they are\&. This is
a one-way ANOVA test\&. The groups may also be stored in a nested list:
The procedure returns a list of the comparison results for each pair of groups\&. Each
element of this list contains: the index of the first group and that of the second group,
whether the means are likely to be different (1) or not (0) and the confidence interval
the conclusion is based on\&. The groups may also be stored in a nested list:
.CS


    test-anova-F 0\&.05 $A $B $C
    #
    # Or equivalently:
    #
    test-anova-F 0\&.05 [list $A $B $C]

.CE
.RS
.TP
float \fIalpha\fR
- Significance level
.TP
list \fIargs\fR
- Two or more groups of data to be checked
.RE
.sp
.TP
\fB::math::statistics::test-Tukey-range\fR \fIalpha\fR \fIargs\fR
Determine if two or more groups with normally distributed data have the same means,
using Tukey's range test\&. It is complementary to the ANOVA test\&.
The procedure returns a list of the comparison results for each pair of groups\&. Each
element of this list contains: the index of the first group and that of the second group,
whether the means are likely to be different (1) or not (0) and the confidence interval
the conclusion is based on\&. The groups may also be stored in a nested list, just as with
the ANOVA test\&.
.RS
.TP
float \fIalpha\fR
- Significance level - either 0\&.05 or 0\&.01
.TP
list \fIargs\fR
- Two or more groups of data to be checked
.RE
.sp
.TP
\fB::math::statistics::test-Dunnett\fR \fIalpha\fR \fIcontrol\fR \fIargs\fR
Determine if one or more groups with normally distributed data have the same means as
the group of control data, using Dunnett's test\&. It is complementary to the ANOVA test\&.
The procedure returns a list of the comparison results for each group with the control group\&. Each
element of this list contains: whether the means are likely to be different (1) or not (0)
and the confidence interval the conclusion is based on\&. The groups may also be stored in a
nested list, just as with the ANOVA test\&.
.sp
Note: some care is required if there is only one group to compare the control with:
.CS


    test-Dunnett-F 0\&.05 $control [list $A]

.CE
.IP
Otherwise the group A is split up into groups of one element - this is due to an ambiguity\&.
.RS
.TP
float \fIalpha\fR
- Significance level - either 0\&.05 or 0\&.01
.TP
list \fIargs\fR
- One or more groups of data to be checked
.RE
.sp
.TP
\fB::math::statistics::quantiles\fR \fIdata\fR \fIconfidence\fR
Return the quantiles for a given set of data
.RS
.TP
list \fIdata\fR
- List of raw data values
.sp
.TP
float \fIconfidence\fR
- Confidence level (0\&.95 or 0\&.99 for instance) or a list of confidence levels\&.
.sp
.RE
.sp
.TP
\fB::math::statistics::quantiles\fR \fIlimits\fR \fIcounts\fR \fIconfidence\fR
Return the quantiles based on histogram information (alternative to the
call with two arguments)
.RS
.TP
list \fIlimits\fR
- List of upper limits from histogram
.TP
list \fIcounts\fR
- List of counts for for each interval in histogram
.TP
float \fIconfidence\fR
-  Confidence level (0\&.95 or 0\&.99 for instance) or a list of confidence levels\&.
.RE
.sp
.TP
\fB::math::statistics::autocorr\fR \fIdata\fR
Return the autocorrelation function as a list of values (assuming
equidistance between samples, about 1/2 of the number of raw data)
.sp
The correlation is determined in such a way that the first value is
always 1 and all others are equal to or smaller than 1\&. The number of
values involved will diminish as the "time" (the index in the list of
returned values) increases
.RS
.TP
list \fIdata\fR
- Raw data for which the autocorrelation must be determined
.RE
.sp
.TP
\fB::math::statistics::crosscorr\fR \fIdata1\fR \fIdata2\fR
Return the cross-correlation function as a list of values (assuming
equidistance between samples, about 1/2 of the number of raw data)
.sp
The correlation is determined in such a way that the values can never
exceed 1 in magnitude\&. The number of values involved will diminish
as the "time" (the index in the list of returned values) increases\&.
.RS
.TP
list \fIdata1\fR
- First list of data
.TP
list \fIdata2\fR
- Second list of data
.RE
.sp
.TP
\fB::math::statistics::mean-histogram-limits\fR \fImean\fR \fIstdev\fR \fInumber\fR
Determine reasonable limits based on mean and standard deviation
for a histogram
Convenience function - the result is suitable for the histogram function\&.
.RS
.TP
float \fImean\fR
- Mean of the data
.TP
float \fIstdev\fR
- Standard deviation
.TP
int \fInumber\fR
- Number of limits to generate (defaults to 8)
.RE
.sp
.TP
\fB::math::statistics::minmax-histogram-limits\fR \fImin\fR \fImax\fR \fInumber\fR
Determine reasonable limits based on a minimum and maximum for a histogram
.sp
Convenience function - the result is suitable for the histogram function\&.
.RS
.TP
float \fImin\fR
- Expected minimum
.TP
float \fImax\fR
- Expected maximum
.TP
int \fInumber\fR
- Number of limits to generate (defaults to 8)
.RE
.sp
.TP
\fB::math::statistics::linear-model\fR \fIxdata\fR \fIydata\fR \fIintercept\fR
Determine the coefficients for a linear regression between
two series of data (the model: Y = A + B*X)\&. Returns a list of
parameters describing the fit
.RS
.TP
list \fIxdata\fR
- List of independent data
.TP
list \fIydata\fR
- List of dependent data to be fitted
.TP
boolean \fIintercept\fR
- (Optional) compute the intercept (1, default) or fit
to a line through the origin (0)
.sp
The result consists of the following list:
.RS
.IP \(bu
(Estimate of) Intercept A
.IP \(bu
(Estimate of) Slope B
.IP \(bu
Standard deviation of Y relative to fit
.IP \(bu
Correlation coefficient R2
.IP \(bu
Number of degrees of freedom df
.IP \(bu
Standard error of the intercept A
.IP \(bu
Significance level of A
.IP \(bu
Standard error of the slope B
.IP \(bu
Significance level of B
.RE
.RE
.sp
.TP
\fB::math::statistics::linear-residuals\fR \fIxdata\fR \fIydata\fR \fIintercept\fR
Determine the difference between actual data and predicted from
the linear model\&.
.sp
Returns a list of the differences between the actual data and the
predicted values\&.
.RS
.TP
list \fIxdata\fR
- List of independent data
.TP
list \fIydata\fR
- List of dependent data to be fitted
.TP
boolean \fIintercept\fR
- (Optional) compute the intercept (1, default) or fit
to a line through the origin (0)
.RE
.sp
.TP
\fB::math::statistics::test-2x2\fR \fIn11\fR \fIn21\fR \fIn12\fR \fIn22\fR
Determine if two set of samples, each from a binomial distribution,
differ significantly or not (implying a different parameter)\&.
.sp
Returns the "chi-square" value, which can be used to the determine the
significance\&.
.RS
.TP
int \fIn11\fR
- Number of outcomes with the first value from the first sample\&.
.TP
int \fIn21\fR
- Number of outcomes with the first value from the second sample\&.
.TP
int \fIn12\fR
- Number of outcomes with the second value from the first sample\&.
.TP
int \fIn22\fR
- Number of outcomes with the second value from the second sample\&.
.RE
.sp
.TP
\fB::math::statistics::print-2x2\fR \fIn11\fR \fIn21\fR \fIn12\fR \fIn22\fR
Determine if two set of samples, each from a binomial distribution,
differ significantly or not (implying a different parameter)\&.
.sp
Returns a short report, useful in an interactive session\&.
.RS
.TP
int \fIn11\fR
- Number of outcomes with the first value from the first sample\&.
.TP
int \fIn21\fR
- Number of outcomes with the first value from the second sample\&.
.TP
int \fIn12\fR
- Number of outcomes with the second value from the first sample\&.
.TP
int \fIn22\fR
- Number of outcomes with the second value from the second sample\&.
.RE
.sp
.TP
\fB::math::statistics::control-xbar\fR \fIdata\fR ?nsamples?
Determine the control limits for an xbar chart\&. The number of data
in each subsample defaults to 4\&. At least 20 subsamples are required\&.
.sp
Returns the mean, the lower limit, the upper limit and the number of
data per subsample\&.
.RS
.TP
list \fIdata\fR
- List of observed data
.TP
int \fInsamples\fR
- Number of data per subsample
.RE
.sp
.TP
\fB::math::statistics::control-Rchart\fR \fIdata\fR ?nsamples?
Determine the control limits for an R chart\&. The number of data
in each subsample (nsamples) defaults to 4\&. At least 20 subsamples are required\&.
.sp
Returns the mean range, the lower limit, the upper limit and the number
of data per subsample\&.
.RS
.TP
list \fIdata\fR
- List of observed data
.TP
int \fInsamples\fR
- Number of data per subsample
.RE
.sp
.TP
\fB::math::statistics::test-xbar\fR \fIcontrol\fR \fIdata\fR
Determine if the data exceed the control limits for the xbar chart\&.
.sp
Returns a list of subsamples (their indices) that indeed violate the
limits\&.
.RS
.TP
list \fIcontrol\fR
- Control limits as returned by the "control-xbar" procedure
.TP
list \fIdata\fR
- List of observed data
.RE
.sp
.TP
\fB::math::statistics::test-Rchart\fR \fIcontrol\fR \fIdata\fR
Determine if the data exceed the control limits for the R chart\&.
.sp
Returns a list of subsamples (their indices) that indeed violate the
limits\&.
.RS
.TP
list \fIcontrol\fR
- Control limits as returned by the "control-Rchart" procedure
.TP
list \fIdata\fR
- List of observed data
.RE
.sp
.TP
\fB::math::statistics::test-Kruskal-Wallis\fR \fIconfidence\fR \fIargs\fR
Check if the population medians of two or more groups are equal with a
given confidence level, using the Kruskal-Wallis test\&.
.RS
.TP
float \fIconfidence\fR
- Confidence level to be used (0-1)
.TP
list \fIargs\fR
- Two or more lists of data
.RE
.sp
.TP
\fB::math::statistics::analyse-Kruskal-Wallis\fR \fIargs\fR
Compute the statistical parameters for the Kruskal-Wallis test\&.
Returns the Kruskal-Wallis statistic and the probability that that
value would occur assuming the medians of the populations are
equal\&.
.RS
.TP
list \fIargs\fR
- Two or more lists of data
.RE
.sp
.TP
\fB::math::statistics::test-Levene\fR \fIgroups\fR
Compute the Levene statistic to determine if groups of data have the
same variance (are homoscadastic) or not\&. The data are organised
in groups\&. This version uses the mean of the data as the measure
to determine the deviations\&. The statistic is equivalent to an
F statistic with degrees of freedom k-1 and N-k, k being the
number of groups and N the total number of data\&.
.RS
.TP
list \fIgroups\fR
- List of groups of data
.RE
.sp
.TP
\fB::math::statistics::test-Brown-Forsythe\fR \fIgroups\fR
Compute the Brown-Forsythe statistic to determine if groups of data have the
same variance (are homoscadastic) or not\&. Like the Levene test, but this
version uses the median of the data\&.
.RS
.TP
list \fIgroups\fR
- List of groups of data
.RE
.sp
.TP
\fB::math::statistics::group-rank\fR \fIargs\fR
Rank the groups of data with respect to the complete set\&.
Returns a list consisting of the group ID, the value and the rank
(possibly a rational number, in case of ties) for each data item\&.
.RS
.TP
list \fIargs\fR
- Two or more lists of data
.RE
.sp
.TP
\fB::math::statistics::test-Wilcoxon\fR \fIsample_a\fR \fIsample_b\fR
Compute the Wilcoxon test statistic to determine if two samples have the
same median or not\&. (The statistic can be regarded as standard normal, if the
sample sizes are both larger than 10\&.) Returns the value of this statistic\&.
.RS
.TP
list \fIsample_a\fR
- List of data comprising the first sample
.TP
list \fIsample_b\fR
- List of data comprising the second sample
.RE
.sp
.TP
\fB::math::statistics::spearman-rank\fR \fIsample_a\fR \fIsample_b\fR
Return the Spearman rank correlation as an alternative to the ordinary (Pearson's) correlation
coefficient\&. The two samples should have the same number of data\&.
.RS
.TP
list \fIsample_a\fR
- First list of data
.TP
list \fIsample_b\fR
- Second list of data
.RE
.sp
.TP
\fB::math::statistics::spearman-rank-extended\fR \fIsample_a\fR \fIsample_b\fR
Return the Spearman rank correlation as an alternative to the ordinary (Pearson's) correlation
coefficient as well as additional data\&. The two samples should have the same number of data\&.
The procedure returns the correlation coefficient, the number of data pairs used and the
z-score, an approximately standard normal statistic, indicating the significance of the correlation\&.
.RS
.TP
list \fIsample_a\fR
- First list of data
.TP
list \fIsample_b\fR
- Second list of data
.RE
.TP
\fB::math::statistics::kernel-density\fR \fIdata\fR opt \fI-option value\fR \&.\&.\&.
Return the density function based on kernel density estimation\&. The procedure is controlled by
a small set of options, each of which is given a reasonable default\&.
.sp
The return value consists of three lists: the centres of the bins, the associated probability
density and a list of computational parameters (begin and end of the interval, mean and standard
deviation and the used bandwidth)\&. The computational parameters can be used for further analysis\&.
.RS
.TP
list \fIdata\fR
- The data to be examined
.TP
list \fIargs\fR
- Option-value pairs:
.RS
.TP
\fB-weights\fR \fIweights\fR
Per data point the weight (default: 1 for all data)
.TP
\fB-bandwidth\fR \fIvalue\fR
Bandwidth to be used for the estimation (default: determined from standard deviation)
.TP
\fB-number\fR \fIvalue\fR
Number of bins to be returned (default: 100)
.TP
\fB-interval\fR \fI{begin end}\fR
Begin and end of the interval for
which the density is returned (default: mean +/- 3*standard deviation)
.TP
\fB-kernel\fR \fIfunction\fR
Kernel to be used (One of: gaussian, cosine,
epanechnikov, uniform, triangular, biweight, logistic; default: gaussian)
.RE
.RE
.TP
\fB::math::statistics::bootstrap\fR \fIdata\fR \fIsampleSize\fR ?numberSamples?
Create a subsample or subsamples from a given list of data\&. The data in the samples are chosen
from this list - multiples may occur\&. If there is only one subsample, the sample itself
is returned (as a list of "sampleSize" values), otherwise a list of samples is returned\&.
.RS
.TP
list \fIdata\fR
List of values to chose from
.TP
int \fIsampleSize\fR
Number of values per sample
.TP
int \fInumberSamples\fR
Number of samples (default: 1)
.RE
.TP
\fB::math::statistics::wasserstein-distance\fR \fIprob1\fR \fIprob2\fR
Compute the Wasserstein distance or earth mover's distance for two equidstantly spaced histograms
or probability densities\&. The histograms need not to be normalised to sum to one,
but they must have the same number of entries\&.
.sp
Note: the histograms are assumed to be based on the same equidistant intervals\&.
As the bounds are not passed, the value is expressed in the length of the intervals\&.
.RS
.TP
list \fIprob1\fR
List of values for the first histogram/probability density
.TP
list \fIprob2\fR
List of values for the second histogram/probability density
.RE
.TP
\fB::math::statistics::kl-divergence\fR \fIprob1\fR \fIprob2\fR
Compute the Kullback-Leibler (KL) divergence for two equidstantly spaced histograms
or probability densities\&. The histograms need not to be normalised to sum to one,
but they must have the same number of entries\&.
.sp
Note: the histograms are assumed to be based on the same equidistant intervals\&.
As the bounds are not passed, the value is expressed in the length of the intervals\&.
.sp
Note also that the KL divergence is not symmetric and that the second histogram
should not contain zeroes in places where the first histogram has non-zero values\&.
.RS
.TP
list \fIprob1\fR
List of values for the first histogram/probability density
.TP
list \fIprob2\fR
List of values for the second histogram/probability density
.RE
.TP
\fB::math::statistics::logistic-model\fR \fIxdata\fR \fIydata\fR
Estimate the coefficients of the logistic model that fits the data best\&. The data consist
of independent x-values and the outcome 0 or 1 for each of the x-values\&. The result
can be used to estimate the probability that a certain x-value gives 1\&.
.RS
.TP
list \fIxdata\fR
List of values for which the success (1) or failure (0) is known
.TP
list \fIydata\fR
List of successes or failures corresponding to each value in \fIxdata\fR\&.
.RE
.TP
\fB::math::statistics::logistic-probability\fR \fIcoeffs\fR \fIx\fR
Calculate the probability of success for the value \fIx\fR given the coefficients of the
logistic model\&.
.RS
.TP
list \fIcoeffs\fR
List of coefficients as determine by the \fBlogistic-model\fR command
.TP
float \fIx\fR
X-value for which the probability needs to be determined
.RE
.PP
.SH "MULTIVARIATE LINEAR REGRESSION"
Besides the linear regression with a single independent variable, the
statistics package provides two procedures for doing ordinary
least squares (OLS) and weighted least squares (WLS) linear regression
with several variables\&. They were written by Eric Kemp-Benedict\&.
.PP
In addition to these two, it provides a procedure (tstat)
for calculating the value of the t-statistic for the specified number of
degrees of freedom that is required to demonstrate a given level of
significance\&.
.PP
Note: These procedures depend on the math::linearalgebra package\&.
.PP
\fIDescription of the procedures\fR
.TP
\fB::math::statistics::tstat\fR \fIdof\fR ?alpha?
Returns the value of the t-distribution t* satisfying
.CS


    P(t*)  =  1 - alpha/2
    P(-t*) =  alpha/2

.CE
.IP
for the number of degrees of freedom dof\&.
.sp
Given a sample of normally-distributed data x, with an
estimate xbar for the mean and sbar for the standard deviation,
the alpha confidence interval for the estimate of the mean can
be calculated as
.CS


      ( xbar - t* sbar , xbar + t* sbar)

.CE
.IP
The return values from this procedure can be compared to
an estimated t-statistic to determine whether the estimated
value of a parameter is significantly different from zero at
the given confidence level\&.
.RS
.TP
int \fIdof\fR
Number of degrees of freedom
.TP
float \fIalpha\fR
Confidence level of the t-distribution\&. Defaults to 0\&.05\&.
.RE
.sp
.TP
\fB::math::statistics::mv-wls\fR \fIweights_and_values\fR
Carries out a weighted least squares linear regression for
the data points provided, with weights assigned to each point\&.
.sp
The linear model is of the form
.CS


    y = b0 + b1 * x1 + b2 * x2 \&.\&.\&. + bN * xN + error

.CE
.IP
and each point satisfies
.CS


    yi = b0 + b1 * xi1 + b2 * xi2 + \&.\&.\&. + bN * xiN + Residual_i

.CE
.sp
The procedure returns a list with the following elements:
.RS
.IP \(bu
The r-squared statistic
.IP \(bu
The adjusted r-squared statistic
.IP \(bu
A list containing the estimated coefficients b1, \&.\&.\&. bN, b0
(The constant b0 comes last in the list\&.)
.IP \(bu
A list containing the standard errors of the coefficients
.IP \(bu
A list containing the 95% confidence bounds of the coefficients,
with each set of bounds returned as a list with two values
.RE
.IP
Arguments:
.RS
.TP
list \fIweights_and_values\fR
A list consisting of: the weight for the first observation, the data
for the first observation (as a sublist), the weight for the second
observation (as a sublist) and so on\&. The sublists of data are organised
as lists of the value of the dependent variable y and the independent
variables x1, x2 to xN\&.
.RE
.IP
\fIExample of the use:\fR
The weight factors are quite simple: 0\&.2 for negative values to indicate
we put less trust in these observations and 1\&.0 for all positive values\&.
.CS


# Store the value of the unicode value for the "+/-" character
set pm "\\u00B1"

# Provide some data
set data { 0\&.2 {  -\&.67  14\&.18  60\&.03 -7\&.5  }
           1\&.0 { 36\&.97  15\&.52  34\&.24 14\&.61 }
           0\&.2 {-29\&.57  21\&.85  83\&.36 -7\&.   }
           0\&.2 {-16\&.9   11\&.79  51\&.67 -6\&.56 }
           1\&.0 { 14\&.09  16\&.24  36\&.97 -12\&.84}
           1\&.0 { 31\&.52  20\&.93  45\&.99 -25\&.4 }
           1\&.0 { 24\&.05  20\&.69  50\&.27  17\&.27}
           1\&.0 { 22\&.23  16\&.91  45\&.07  -4\&.3 }
           1\&.0 { 40\&.79  20\&.49  38\&.92  -\&.73 }
           0\&.2 {-10\&.35  17\&.24  58\&.77  18\&.78}}

# Call the ols routine
set results [::math::statistics::mv-ols $data]

# Pretty-print the results
puts "R-squared: [lindex $results 0]"
puts "Adj R-squared: [lindex $results 1]"
puts "Coefficients $pm s\&.e\&. -- \\[95% confidence interval\\]:"
foreach val [lindex $results 2] se [lindex $results 3] bounds [lindex $results 4] {
    set lb [lindex $bounds 0]
    set ub [lindex $bounds 1]
    puts "   $val $pm $se -- \\[$lb to $ub\\]"
}

.CE
.sp
.TP
\fB::math::statistics::mv-ols\fR \fIvalues\fR
Carries out an ordinary least squares linear regression for
the data points provided\&.
.sp
This procedure simply calls ::mvlinreg::wls with the weights
set to 1\&.0, and returns the same information\&.
.PP
\fIExample of the use:\fR
.CS


# Store the value of the unicode value for the "+/-" character
set pm "\\u00B1"

# Provide some data
set data {{  -\&.67  14\&.18  60\&.03 -7\&.5  }
          { 36\&.97  15\&.52  34\&.24 14\&.61 }
          {-29\&.57  21\&.85  83\&.36 -7\&.   }
          {-16\&.9   11\&.79  51\&.67 -6\&.56 }
          { 14\&.09  16\&.24  36\&.97 -12\&.84}
          { 31\&.52  20\&.93  45\&.99 -25\&.4 }
          { 24\&.05  20\&.69  50\&.27  17\&.27}
          { 22\&.23  16\&.91  45\&.07  -4\&.3 }
          { 40\&.79  20\&.49  38\&.92  -\&.73 }
          {-10\&.35  17\&.24  58\&.77  18\&.78}}

# Call the ols routine
set results [::math::statistics::mv-ols $data]

# Pretty-print the results
puts "R-squared: [lindex $results 0]"
puts "Adj R-squared: [lindex $results 1]"
puts "Coefficients $pm s\&.e\&. -- \\[95% confidence interval\\]:"
foreach val [lindex $results 2] se [lindex $results 3] bounds [lindex $results 4] {
    set lb [lindex $bounds 0]
    set ub [lindex $bounds 1]
    puts "   $val $pm $se -- \\[$lb to $ub\\]"
}

.CE
.SH "STATISTICAL DISTRIBUTIONS"
In the literature a large number of probability distributions can be
found\&. The statistics package supports:
.IP \(bu
The normal or Gaussian distribution as well as the log-normal distribution
.IP \(bu
The uniform distribution - equal probability for all data within a given
interval
.IP \(bu
The exponential distribution - useful as a model for certain
extreme-value distributions\&.
.IP \(bu
The gamma distribution - based on the incomplete Gamma integral
.IP \(bu
The beta distribution
.IP \(bu
The chi-square distribution
.IP \(bu
The student's T distribution
.IP \(bu
The Poisson distribution
.IP \(bu
The Pareto distribution
.IP \(bu
The Gumbel distribution
.IP \(bu
The Weibull distribution
.IP \(bu
The Cauchy distribution
.IP \(bu
The F distribution (only the cumulative density function)
.IP \(bu
PM - binomial\&.
.PP
In principle for each distribution one has procedures for:
.IP \(bu
The probability density (pdf-*)
.IP \(bu
The cumulative density (cdf-*)
.IP \(bu
Quantiles for the given distribution (quantiles-*)
.IP \(bu
Histograms for the given distribution (histogram-*)
.IP \(bu
List of random values with the given distribution (random-*)
.PP
The following procedures have been implemented:
.TP
\fB::math::statistics::pdf-normal\fR \fImean\fR \fIstdev\fR \fIvalue\fR
Return the probability of a given value for a normal distribution with
given mean and standard deviation\&.
.RS
.TP
float \fImean\fR
- Mean value of the distribution
.TP
float \fIstdev\fR
- Standard deviation of the distribution
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::pdf-lognormal\fR \fImean\fR \fIstdev\fR \fIvalue\fR
Return the probability of a given value for a log-normal distribution with
given mean and standard deviation\&.
.RS
.TP
float \fImean\fR
- Mean value of the distribution
.TP
float \fIstdev\fR
- Standard deviation of the distribution
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::pdf-exponential\fR \fImean\fR \fIvalue\fR
Return the probability of a given value for an exponential
distribution with given mean\&.
.RS
.TP
float \fImean\fR
- Mean value of the distribution
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::pdf-uniform\fR \fIxmin\fR \fIxmax\fR \fIvalue\fR
Return the probability of a given value for a uniform
distribution with given extremes\&.
.RS
.TP
float \fIxmin\fR
- Minimum value of the distribution
.TP
float \fIxmin\fR
- Maximum value of the distribution
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::pdf-triangular\fR \fIxmin\fR \fIxmax\fR \fIvalue\fR
Return the probability of a given value for a triangular
distribution with given extremes\&. If the argument min is lower than the argument max, then smaller
values have higher probability and vice versa\&. In the first case the probability
density function is of the form \fIf(x) = 2(1-x)\fR and the other case it is of the form \fIf(x) = 2x\fR\&.
.RS
.TP
float \fIxmin\fR
- Minimum value of the distribution
.TP
float \fIxmin\fR
- Maximum value of the distribution
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::pdf-symmetric-triangular\fR \fIxmin\fR \fIxmax\fR \fIvalue\fR
Return the probability of a given value for a symmetric triangular
distribution with given extremes\&.
.RS
.TP
float \fIxmin\fR
- Minimum value of the distribution
.TP
float \fIxmin\fR
- Maximum value of the distribution
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::pdf-gamma\fR \fIalpha\fR \fIbeta\fR \fIvalue\fR
Return the probability of a given value for a Gamma
distribution with given shape and rate parameters
.RS
.TP
float \fIalpha\fR
- Shape parameter
.TP
float \fIbeta\fR
- Rate parameter
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::pdf-poisson\fR \fImu\fR \fIk\fR
Return the probability of a given number of occurrences in the same
interval (k) for a Poisson distribution with given mean (mu)
.RS
.TP
float \fImu\fR
- Mean number of occurrences
.TP
int \fIk\fR
- Number of occurences
.RE
.sp
.TP
\fB::math::statistics::pdf-chisquare\fR \fIdf\fR \fIvalue\fR
Return the probability of a given value for a chi square
distribution with given degrees of freedom
.RS
.TP
float \fIdf\fR
- Degrees of freedom
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::pdf-student-t\fR \fIdf\fR \fIvalue\fR
Return the probability of a given value for a Student's t
distribution with given degrees of freedom
.RS
.TP
float \fIdf\fR
- Degrees of freedom
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::pdf-gamma\fR \fIa\fR \fIb\fR \fIvalue\fR
Return the probability of a given value for a Gamma
distribution with given shape and rate parameters
.RS
.TP
float \fIa\fR
- Shape parameter
.TP
float \fIb\fR
- Rate parameter
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::pdf-beta\fR \fIa\fR \fIb\fR \fIvalue\fR
Return the probability of a given value for a Beta
distribution with given shape parameters
.RS
.TP
float \fIa\fR
- First shape parameter
.TP
float \fIb\fR
- Second shape parameter
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::pdf-weibull\fR \fIscale\fR \fIshape\fR \fIvalue\fR
Return the probability of a given value for a Weibull
distribution with given scale and shape parameters
.RS
.TP
float \fIlocation\fR
- Scale parameter
.TP
float \fIscale\fR
- Shape parameter
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::pdf-gumbel\fR \fIlocation\fR \fIscale\fR \fIvalue\fR
Return the probability of a given value for a Gumbel
distribution with given location and shape parameters
.RS
.TP
float \fIlocation\fR
- Location parameter
.TP
float \fIscale\fR
- Shape parameter
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::pdf-pareto\fR \fIscale\fR \fIshape\fR \fIvalue\fR
Return the probability of a given value for a Pareto
distribution with given scale and shape parameters
.RS
.TP
float \fIscale\fR
- Scale parameter
.TP
float \fIshape\fR
- Shape parameter
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::pdf-cauchy\fR \fIlocation\fR \fIscale\fR \fIvalue\fR
Return the probability of a given value for a Cauchy
distribution with given location and shape parameters\&. Note that the Cauchy distribution
has no finite higher-order moments\&.
.RS
.TP
float \fIlocation\fR
- Location parameter
.TP
float \fIscale\fR
- Shape parameter
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::pdf-laplace\fR \fIlocation\fR \fIscale\fR \fIvalue\fR
Return the probability of a given value for a Laplace
distribution with given location and shape parameters\&. The Laplace distribution
consists of two exponential functions, is peaked and has heavier tails than the
normal distribution\&.
.RS
.TP
float \fIlocation\fR
- Location parameter (mean)
.TP
float \fIscale\fR
- Shape parameter
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::pdf-kumaraswamy\fR \fIa\fR \fIb\fR \fIvalue\fR
Return the probability of a given value for a Kumaraswamy
distribution with given parameters a and b\&. The Kumaraswamy distribution
is related to the Beta distribution, but has a tractable cumulative distribution function\&.
.RS
.TP
float \fIa\fR
- Parameter a
.TP
float \fIb\fR
- Parameter b
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::pdf-negative-binomial\fR \fIr\fR \fIp\fR \fIvalue\fR
Return the probability of a given value for a negative binomial
distribution with an allowed number of failures and the probability of success\&.
.RS
.TP
int \fIr\fR
- Allowed number of failures (at least 1)
.TP
float \fIp\fR
- Probability of success
.TP
int \fIvalue\fR
- Number of successes for which the probability is to be returned
.RE
.sp
.TP
\fB::math::statistics::cdf-normal\fR \fImean\fR \fIstdev\fR \fIvalue\fR
Return the cumulative probability of a given value for a normal
distribution with given mean and standard deviation, that is the
probability for values up to the given one\&.
.RS
.TP
float \fImean\fR
- Mean value of the distribution
.TP
float \fIstdev\fR
- Standard deviation of the distribution
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::cdf-lognormal\fR \fImean\fR \fIstdev\fR \fIvalue\fR
Return the cumulative probability of a given value for a log-normal
distribution with given mean and standard deviation, that is the
probability for values up to the given one\&.
.RS
.TP
float \fImean\fR
- Mean value of the distribution
.TP
float \fIstdev\fR
- Standard deviation of the distribution
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::cdf-exponential\fR \fImean\fR \fIvalue\fR
Return the cumulative probability of a given value for an exponential
distribution with given mean\&.
.RS
.TP
float \fImean\fR
- Mean value of the distribution
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::cdf-uniform\fR \fIxmin\fR \fIxmax\fR \fIvalue\fR
Return the cumulative probability of a given value for a uniform
distribution with given extremes\&.
.RS
.TP
float \fIxmin\fR
- Minimum value of the distribution
.TP
float \fIxmin\fR
- Maximum value of the distribution
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::cdf-triangular\fR \fIxmin\fR \fIxmax\fR \fIvalue\fR
Return the cumulative probability of a given value for a triangular
distribution with given extremes\&. If xmin < xmax, then lower values have
a higher probability and vice versa, see also \fIpdf-triangular\fR
.RS
.TP
float \fIxmin\fR
- Minimum value of the distribution
.TP
float \fIxmin\fR
- Maximum value of the distribution
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::cdf-symmetric-triangular\fR \fIxmin\fR \fIxmax\fR \fIvalue\fR
Return the cumulative probability of a given value for a symmetric triangular
distribution with given extremes\&.
.RS
.TP
float \fIxmin\fR
- Minimum value of the distribution
.TP
float \fIxmin\fR
- Maximum value of the distribution
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::cdf-students-t\fR \fIdegrees\fR \fIvalue\fR
Return the cumulative probability of a given value for a Student's t
distribution with given number of degrees\&.
.RS
.TP
int \fIdegrees\fR
- Number of degrees of freedom
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::cdf-gamma\fR \fIalpha\fR \fIbeta\fR \fIvalue\fR
Return the cumulative probability of a given value for a Gamma
distribution with given shape and rate parameters\&.
.RS
.TP
float \fIalpha\fR
- Shape parameter
.TP
float \fIbeta\fR
- Rate parameter
.TP
float \fIvalue\fR
- Value for which the cumulative probability is required
.RE
.sp
.TP
\fB::math::statistics::cdf-poisson\fR \fImu\fR \fIk\fR
Return the cumulative probability of a given number of occurrences in
the same interval (k) for a Poisson distribution with given mean (mu)\&.
.RS
.TP
float \fImu\fR
- Mean number of occurrences
.TP
int \fIk\fR
- Number of occurences
.RE
.sp
.TP
\fB::math::statistics::cdf-beta\fR \fIa\fR \fIb\fR \fIvalue\fR
Return the cumulative probability of a given value for a Beta
distribution with given shape parameters
.RS
.TP
float \fIa\fR
- First shape parameter
.TP
float \fIb\fR
- Second shape parameter
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::cdf-weibull\fR \fIscale\fR \fIshape\fR \fIvalue\fR
Return the cumulative probability of a given value for a Weibull
distribution with given scale and shape parameters\&.
.RS
.TP
float \fIscale\fR
- Scale parameter
.TP
float \fIshape\fR
- Shape parameter
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::cdf-gumbel\fR \fIlocation\fR \fIscale\fR \fIvalue\fR
Return the cumulative probability of a given value for a Gumbel
distribution with given location and scale parameters\&.
.RS
.TP
float \fIlocation\fR
- Location parameter
.TP
float \fIscale\fR
- Scale parameter
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::cdf-pareto\fR \fIscale\fR \fIshape\fR \fIvalue\fR
Return the cumulative probability of a given value for a Pareto
distribution with given scale and shape parameters
.RS
.TP
float \fIscale\fR
- Scale parameter
.TP
float \fIshape\fR
- Shape parameter
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::cdf-cauchy\fR \fIlocation\fR \fIscale\fR \fIvalue\fR
Return the cumulative probability of a given value for a Cauchy
distribution with given location and scale parameters\&.
.RS
.TP
float \fIlocation\fR
- Location parameter
.TP
float \fIscale\fR
- Scale parameter
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::cdf-F\fR \fInf1\fR \fInf2\fR \fIvalue\fR
Return the cumulative probability of a given value for an F
distribution with nf1 and nf2 degrees of freedom\&.
.RS
.TP
float \fInf1\fR
- Degrees of freedom for the numerator
.TP
float \fInf2\fR
- Degrees of freedom for the denominator
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::cdf-laplace\fR \fIlocation\fR \fIscale\fR \fIvalue\fR
Return the cumulative probability of a given value for a Laplace
distribution with given location and shape parameters\&. The Laplace distribution
consists of two exponential functions, is peaked and has heavier tails than the
normal distribution\&.
.RS
.TP
float \fIlocation\fR
- Location parameter (mean)
.TP
float \fIscale\fR
- Shape parameter
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::cdf-kumaraswamy\fR \fIa\fR \fIb\fR \fIvalue\fR
Return the cumulative probability of a given value for a Kumaraswamy
distribution with given parameters a and b\&. The Kumaraswamy distribution
is related to the Beta distribution, but has a tractable cumulative distribution function\&.
.RS
.TP
float \fIa\fR
- Parameter a
.TP
float \fIb\fR
- Parameter b
.TP
float \fIvalue\fR
- Value for which the probability is required
.RE
.sp
.TP
\fB::math::statistics::cdf-negative-binomial\fR \fIr\fR \fIp\fR \fIvalue\fR
Return the cumulative probability of a given value for a negative binomial
distribution with an allowed number of failures and the probability of success\&.
.RS
.TP
int \fIr\fR
- Allowed number of failures (at least 1)
.TP
float \fIp\fR
- Probability of success
.TP
int \fIvalue\fR
- Greatest number of successes
.RE
.sp
.TP
\fB::math::statistics::empirical-distribution\fR \fIvalues\fR
Return a list of values and their empirical probability\&. The values are sorted in increasing order\&.
(The implementation follows the description at the corresponding Wikipedia page)
.RS
.TP
list \fIvalues\fR
- List of data to be examined
.RE
.sp
.TP
\fB::math::statistics::random-normal\fR \fImean\fR \fIstdev\fR \fInumber\fR
Return a list of "number" random values satisfying a normal
distribution with given mean and standard deviation\&.
.RS
.TP
float \fImean\fR
- Mean value of the distribution
.TP
float \fIstdev\fR
- Standard deviation of the distribution
.TP
int \fInumber\fR
- Number of values to be returned
.RE
.sp
.TP
\fB::math::statistics::random-lognormal\fR \fImean\fR \fIstdev\fR \fInumber\fR
Return a list of "number" random values satisfying a log-normal
distribution with given mean and standard deviation\&.
.RS
.TP
float \fImean\fR
- Mean value of the distribution
.TP
float \fIstdev\fR
- Standard deviation of the distribution
.TP
int \fInumber\fR
- Number of values to be returned
.RE
.sp
.TP
\fB::math::statistics::random-exponential\fR \fImean\fR \fInumber\fR
Return a list of "number" random values satisfying an exponential
distribution with given mean\&.
.RS
.TP
float \fImean\fR
- Mean value of the distribution
.TP
int \fInumber\fR
- Number of values to be returned
.RE
.sp
.TP
\fB::math::statistics::random-uniform\fR \fIxmin\fR \fIxmax\fR \fInumber\fR
Return a list of "number" random values satisfying a uniform
distribution with given extremes\&.
.RS
.TP
float \fIxmin\fR
- Minimum value of the distribution
.TP
float \fIxmax\fR
- Maximum value of the distribution
.TP
int \fInumber\fR
- Number of values to be returned
.RE
.sp
.TP
\fB::math::statistics::random-triangular\fR \fIxmin\fR \fIxmax\fR \fInumber\fR
Return a list of "number" random values satisfying a triangular
distribution with given extremes\&. If xmin < xmax, then lower values have a higher probability
and vice versa (see also \fIpdf-triangular\fR\&.
.RS
.TP
float \fIxmin\fR
- Minimum value of the distribution
.TP
float \fIxmax\fR
- Maximum value of the distribution
.TP
int \fInumber\fR
- Number of values to be returned
.RE
.sp
.TP
\fB::math::statistics::random-symmetric-triangular\fR \fIxmin\fR \fIxmax\fR \fInumber\fR
Return a list of "number" random values satisfying a symmetric triangular
distribution with given extremes\&.
.RS
.TP
float \fIxmin\fR
- Minimum value of the distribution
.TP
float \fIxmax\fR
- Maximum value of the distribution
.TP
int \fInumber\fR
- Number of values to be returned
.RE
.sp
.TP
\fB::math::statistics::random-gamma\fR \fIalpha\fR \fIbeta\fR \fInumber\fR
Return a list of "number" random values satisfying
a Gamma distribution with given shape and rate parameters\&.
.RS
.TP
float \fIalpha\fR
- Shape parameter
.TP
float \fIbeta\fR
- Rate parameter
.TP
int \fInumber\fR
- Number of values to be returned
.RE
.sp
.TP
\fB::math::statistics::random-poisson\fR \fImu\fR \fInumber\fR
Return a list of "number" random values satisfying
a Poisson distribution with given mean\&.
.RS
.TP
float \fImu\fR
- Mean of the distribution
.TP
int \fInumber\fR
- Number of values to be returned
.RE
.sp
.TP
\fB::math::statistics::random-chisquare\fR \fIdf\fR \fInumber\fR
Return a list of "number" random values satisfying
a chi square distribution with given degrees of freedom\&.
.RS
.TP
float \fIdf\fR
- Degrees of freedom
.TP
int \fInumber\fR
- Number of values to be returned
.RE
.sp
.TP
\fB::math::statistics::random-student-t\fR \fIdf\fR \fInumber\fR
Return a list of "number" random values satisfying
a Student's t distribution with given degrees of freedom\&.
.RS
.TP
float \fIdf\fR
- Degrees of freedom
.TP
int \fInumber\fR
- Number of values to be returned
.RE
.sp
.TP
\fB::math::statistics::random-beta\fR \fIa\fR \fIb\fR \fInumber\fR
Return a list of "number" random values satisfying
a Beta distribution with given shape parameters\&.
.RS
.TP
float \fIa\fR
- First shape parameter
.TP
float \fIb\fR
- Second shape parameter
.TP
int \fInumber\fR
- Number of values to be returned
.RE
.sp
.TP
\fB::math::statistics::random-weibull\fR \fIscale\fR \fIshape\fR \fInumber\fR
Return a list of "number" random values satisfying
a Weibull distribution with given scale and shape parameters\&.
.RS
.TP
float \fIscale\fR
- Scale parameter
.TP
float \fIshape\fR
- Shape parameter
.TP
int \fInumber\fR
- Number of values to be returned
.RE
.sp
.TP
\fB::math::statistics::random-gumbel\fR \fIlocation\fR \fIscale\fR \fInumber\fR
Return a list of "number" random values satisfying
a Gumbel distribution with given location and scale parameters\&.
.RS
.TP
float \fIlocation\fR
- Location parameter
.TP
float \fIscale\fR
- Scale parameter
.TP
int \fInumber\fR
- Number of values to be returned
.RE
.sp
.TP
\fB::math::statistics::random-pareto\fR \fIscale\fR \fIshape\fR \fInumber\fR
Return a list of "number" random values satisfying
a Pareto distribution with given scale and shape parameters\&.
.RS
.TP
float \fIscale\fR
- Scale parameter
.TP
float \fIshape\fR
- Shape parameter
.TP
int \fInumber\fR
- Number of values to be returned
.RE
.sp
.TP
\fB::math::statistics::random-cauchy\fR \fIlocation\fR \fIscale\fR \fInumber\fR
Return a list of "number" random values satisfying
a Cauchy distribution with given location and scale parameters\&.
.RS
.TP
float \fIlocation\fR
- Location parameter
.TP
float \fIscale\fR
- Scale parameter
.TP
int \fInumber\fR
- Number of values to be returned
.RE
.sp
.TP
\fB::math::statistics::random-laplace\fR \fIlocation\fR \fIscale\fR \fInumber\fR
Return a list of "number" random values satisfying a Laplace
distribution with given location and shape parameters\&. The Laplace distribution
consists of two exponential functions, is peaked and has heavier tails than the
normal distribution\&.
.RS
.TP
float \fIlocation\fR
- Location parameter (mean)
.TP
float \fIscale\fR
- Shape parameter
.TP
int \fInumber\fR
- Number of values to be returned
.RE
.sp
.TP
\fB::math::statistics::random-kumaraswamy\fR \fIa\fR \fIb\fR \fInumber\fR
Return a list of "number" random values satisying a Kumaraswamy
distribution with given parameters a and b\&. The Kumaraswamy distribution
is related to the Beta distribution, but has a tractable cumulative distribution function\&.
.RS
.TP
float \fIa\fR
- Parameter a
.TP
float \fIb\fR
- Parameter b
.TP
int \fInumber\fR
- Number of values to be returned
.RE
.sp
.TP
\fB::math::statistics::random-negative-binomial\fR \fIr\fR \fIp\fR \fInumber\fR
Return a list of "number" random values satisying a negative binomial distribution\&.
.RS
.TP
int \fIr\fR
- Allowed number of failures (at least 1)
.TP
float \fIp\fR
- Probability of success
.TP
int \fInumber\fR
- Number of values to be returned
.RE
.sp
.TP
\fB::math::statistics::histogram-uniform\fR \fIxmin\fR \fIxmax\fR \fIlimits\fR \fInumber\fR
Return the expected histogram for a uniform distribution\&.
.RS
.TP
float \fIxmin\fR
- Minimum value of the distribution
.TP
float \fIxmax\fR
- Maximum value of the distribution
.TP
list \fIlimits\fR
- Upper limits for the buckets in the histogram
.TP
int \fInumber\fR
- Total number of "observations" in the histogram
.RE
.sp
.TP
\fB::math::statistics::incompleteGamma\fR \fIx\fR \fIp\fR ?tol?
Evaluate the incomplete Gamma integral
.CS


                    1       / x               p-1
      P(p,x) =  --------   |   dt exp(-t) * t
                Gamma(p)  / 0

.CE
.RS
.TP
float \fIx\fR
- Value of x (limit of the integral)
.TP
float \fIp\fR
- Value of p in the integrand
.TP
float \fItol\fR
- Required tolerance (default: 1\&.0e-9)
.RE
.sp
.TP
\fB::math::statistics::incompleteBeta\fR \fIa\fR \fIb\fR \fIx\fR ?tol?
Evaluate the incomplete Beta integral
.RS
.TP
float \fIa\fR
- First shape parameter
.TP
float \fIb\fR
- Second shape parameter
.TP
float \fIx\fR
- Value of x (limit of the integral)
.TP
float \fItol\fR
- Required tolerance (default: 1\&.0e-9)
.RE
.sp
.TP
\fB::math::statistics::estimate-pareto\fR \fIvalues\fR
Estimate the parameters for the Pareto distribution that comes closest to the given values\&.
Returns the estimated scale and shape parameters, as well as the standard error for the shape parameter\&.
.RS
.TP
list \fIvalues\fR
- List of values, assumed to be distributed according to a Pareto distribution
.RE
.sp
.TP
\fB::math::statistics::estimate-exponential\fR \fIvalues\fR
Estimate the parameter for the exponential distribution that comes closest to the given values\&.
Returns an estimate of the one parameter and of the standard error\&.
.RS
.TP
list \fIvalues\fR
- List of values, assumed to be distributed according to an exponential distribution
.RE
.sp
.TP
\fB::math::statistics::estimate-laplace\fR \fIvalues\fR
Estimate the parameters for the Laplace distribution that comes closest to the given values\&.
Returns an estimate of respectively the location and scale parameters, based on maximum likelihood\&.
.RS
.TP
list \fIvalues\fR
- List of values, assumed to be distributed according to an exponential distribution
.RE
.sp
.TP
\fB::math::statistics::estimante-negative-binomial\fR \fIr\fR \fIvalues\fR
Estimate the probability of success for the negative binomial distribution that comes closest to the given values\&.
The allowed number of failures must be given\&.
.RS
.TP
int \fIr\fR
- Allowed number of failures (at least 1)
.TP
int \fInumber\fR
- List of values, assumed to be distributed according to a negative binomial distribution\&.
.RE
.sp
.PP
TO DO: more function descriptions to be added
.SH "DATA MANIPULATION"
The data manipulation procedures act on lists or lists of lists:
.TP
\fB::math::statistics::filter\fR \fIvarname\fR \fIdata\fR \fIexpression\fR
Return a list consisting of the data for which the logical
expression is true (this command works analogously to the command \fBforeach\fR)\&.
.RS
.TP
string \fIvarname\fR
- Name of the variable used in the expression
.TP
list \fIdata\fR
- List of data
.TP
string \fIexpression\fR
- Logical expression using the variable name
.RE
.sp
.TP
\fB::math::statistics::map\fR \fIvarname\fR \fIdata\fR \fIexpression\fR
Return a list consisting of the data that are transformed via the
expression\&.
.RS
.TP
string \fIvarname\fR
- Name of the variable used in the expression
.TP
list \fIdata\fR
- List of data
.TP
string \fIexpression\fR
- Expression to be used to transform (map) the data
.RE
.sp
.TP
\fB::math::statistics::samplescount\fR \fIvarname\fR \fIlist\fR \fIexpression\fR
Return a list consisting of the \fIcounts\fR of all data in the
sublists of the "list" argument for which the expression is true\&.
.RS
.TP
string \fIvarname\fR
- Name of the variable used in the expression
.TP
list \fIdata\fR
- List of sublists, each containing the data
.TP
string \fIexpression\fR
- Logical expression to test the data (defaults to
"true")\&.
.RE
.sp
.TP
\fB::math::statistics::subdivide\fR
Routine \fIPM\fR - not implemented yet
.sp
.PP
.SH "PLOT PROCEDURES"
The following simple plotting procedures are available:
.TP
\fB::math::statistics::plot-scale\fR \fIcanvas\fR \fIxmin\fR \fIxmax\fR \fIymin\fR \fIymax\fR
Set the scale for a plot in the given canvas\&. All plot routines expect
this function to be called first\&. There is no automatic scaling
provided\&.
.RS
.TP
widget \fIcanvas\fR
- Canvas widget to use
.TP
float \fIxmin\fR
- Minimum x value
.TP
float \fIxmax\fR
- Maximum x value
.TP
float \fIymin\fR
- Minimum y value
.TP
float \fIymax\fR
- Maximum y value
.RE
.sp
.TP
\fB::math::statistics::plot-xydata\fR \fIcanvas\fR \fIxdata\fR \fIydata\fR \fItag\fR
Create a simple XY plot in the given canvas - the data are
shown as a collection of dots\&. The tag can be used to manipulate the
appearance\&.
.RS
.TP
widget \fIcanvas\fR
- Canvas widget to use
.TP
float \fIxdata\fR
- Series of independent data
.TP
float \fIydata\fR
- Series of dependent data
.TP
string \fItag\fR
- Tag to give to the plotted data (defaults to xyplot)
.RE
.sp
.TP
\fB::math::statistics::plot-xyline\fR \fIcanvas\fR \fIxdata\fR \fIydata\fR \fItag\fR
Create a simple XY plot in the given canvas - the data are
shown as a line through the data points\&. The tag can be used to
manipulate the appearance\&.
.RS
.TP
widget \fIcanvas\fR
- Canvas widget to use
.TP
list \fIxdata\fR
- Series of independent data
.TP
list \fIydata\fR
- Series of dependent data
.TP
string \fItag\fR
- Tag to give to the plotted data (defaults to xyplot)
.RE
.sp
.TP
\fB::math::statistics::plot-tdata\fR \fIcanvas\fR \fItdata\fR \fItag\fR
Create a simple XY plot in the given canvas - the data are
shown as a collection of dots\&. The horizontal coordinate is equal to the
index\&. The tag can be used to manipulate the appearance\&.
This type of presentation is suitable for autocorrelation functions for
instance or for inspecting the time-dependent behaviour\&.
.RS
.TP
widget \fIcanvas\fR
- Canvas widget to use
.TP
list \fItdata\fR
- Series of dependent data
.TP
string \fItag\fR
- Tag to give to the plotted data (defaults to xyplot)
.RE
.sp
.TP
\fB::math::statistics::plot-tline\fR \fIcanvas\fR \fItdata\fR \fItag\fR
Create a simple XY plot in the given canvas - the data are
shown as a line\&. See plot-tdata for an explanation\&.
.RS
.TP
widget \fIcanvas\fR
- Canvas widget to use
.TP
list \fItdata\fR
- Series of dependent data
.TP
string \fItag\fR
- Tag to give to the plotted data (defaults to xyplot)
.RE
.sp
.TP
\fB::math::statistics::plot-histogram\fR \fIcanvas\fR \fIcounts\fR \fIlimits\fR \fItag\fR
Create a simple histogram in the given canvas
.RS
.TP
widget \fIcanvas\fR
- Canvas widget to use
.TP
list \fIcounts\fR
- Series of bucket counts
.TP
list \fIlimits\fR
- Series of upper limits for the buckets
.TP
string \fItag\fR
- Tag to give to the plotted data (defaults to xyplot)
.RE
.sp
.PP
.SH "THINGS TO DO"
The following procedures are yet to be implemented:
.IP \(bu
F-test-stdev
.IP \(bu
interval-mean-stdev
.IP \(bu
histogram-normal
.IP \(bu
histogram-exponential
.IP \(bu
test-histogram
.IP \(bu
test-corr
.IP \(bu
quantiles-*
.IP \(bu
fourier-coeffs
.IP \(bu
fourier-residuals
.IP \(bu
onepar-function-fit
.IP \(bu
onepar-function-residuals
.IP \(bu
plot-linear-model
.IP \(bu
subdivide
.PP
.SH EXAMPLES
The code below is a small example of how you can examine a set of
data:
.PP
.CS



# Simple example:
# - Generate data (as a cheap way of getting some)
# - Perform statistical analysis to describe the data
#
package require math::statistics

#
# Two auxiliary procs
#
proc pause {time} {
   set wait 0
   after [expr {$time*1000}] {set ::wait 1}
   vwait wait
}

proc print-histogram {counts limits} {
   foreach count $counts limit $limits {
      if { $limit != {} } {
         puts [format "<%12\&.4g\\t%d" $limit $count]
         set prev_limit $limit
      } else {
         puts [format ">%12\&.4g\\t%d" $prev_limit $count]
      }
   }
}

#
# Our source of arbitrary data
#
proc generateData { data1 data2 } {
   upvar 1 $data1 _data1
   upvar 1 $data2 _data2

   set d1 0\&.0
   set d2 0\&.0
   for { set i 0 } { $i < 100 } { incr i } {
      set d1 [expr {10\&.0-2\&.0*cos(2\&.0*3\&.1415926*$i/24\&.0)+3\&.5*rand()}]
      set d2 [expr {0\&.7*$d2+0\&.3*$d1+0\&.7*rand()}]
      lappend _data1 $d1
      lappend _data2 $d2
   }
   return {}
}

#
# The analysis session
#
package require Tk
console show
canvas \&.plot1
canvas \&.plot2
pack   \&.plot1 \&.plot2 -fill both -side top

generateData data1 data2

puts "Basic statistics:"
set b1 [::math::statistics::basic-stats $data1]
set b2 [::math::statistics::basic-stats $data2]
foreach label {mean min max number stdev var} v1 $b1 v2 $b2 {
   puts "$label\\t$v1\\t$v2"
}
puts "Plot the data as function of \\"time\\" and against each other"
::math::statistics::plot-scale \&.plot1  0 100  0 20
::math::statistics::plot-scale \&.plot2  0 20   0 20
::math::statistics::plot-tline \&.plot1 $data1
::math::statistics::plot-tline \&.plot1 $data2
::math::statistics::plot-xydata \&.plot2 $data1 $data2

puts "Correlation coefficient:"
puts [::math::statistics::corr $data1 $data2]

pause 2
puts "Plot histograms"
\&.plot2 delete all
::math::statistics::plot-scale \&.plot2  0 20 0 100
set limits         [::math::statistics::minmax-histogram-limits 7 16]
set histogram_data [::math::statistics::histogram $limits $data1]
::math::statistics::plot-histogram \&.plot2 $histogram_data $limits

puts "First series:"
print-histogram $histogram_data $limits

pause 2
set limits         [::math::statistics::minmax-histogram-limits 0 15 10]
set histogram_data [::math::statistics::histogram $limits $data2]
::math::statistics::plot-histogram \&.plot2 $histogram_data $limits d2
\&.plot2 itemconfigure d2 -fill red

puts "Second series:"
print-histogram $histogram_data $limits

puts "Autocorrelation function:"
set  autoc [::math::statistics::autocorr $data1]
puts [::math::statistics::map $autoc {[format "%\&.2f" $x]}]
puts "Cross-correlation function:"
set  crossc [::math::statistics::crosscorr $data1 $data2]
puts [::math::statistics::map $crossc {[format "%\&.2f" $x]}]

::math::statistics::plot-scale \&.plot1  0 100 -1  4
::math::statistics::plot-tline \&.plot1  $autoc "autoc"
::math::statistics::plot-tline \&.plot1  $crossc "crossc"
\&.plot1 itemconfigure autoc  -fill green
\&.plot1 itemconfigure crossc -fill yellow

puts "Quantiles: 0\&.1, 0\&.2, 0\&.5, 0\&.8, 0\&.9"
puts "First:  [::math::statistics::quantiles $data1 {0\&.1 0\&.2 0\&.5 0\&.8 0\&.9}]"
puts "Second: [::math::statistics::quantiles $data2 {0\&.1 0\&.2 0\&.5 0\&.8 0\&.9}]"


.CE
If you run this example, then the following should be clear:
.IP \(bu
There is a strong correlation between two time series, as displayed by
the raw data and especially by the correlation functions\&.
.IP \(bu
Both time series show a significant periodic component
.IP \(bu
The histograms are not very useful in identifying the nature of the time
series - they do not show the periodic nature\&.
.PP
.SH "BUGS, IDEAS, FEEDBACK"
This document, and the package it describes, will undoubtedly contain
bugs and other problems\&.
Please report such in the category \fImath :: statistics\fR of the
\fITcllib Trackers\fR [http://core\&.tcl\&.tk/tcllib/reportlist]\&.
Please also report any ideas for enhancements you may have for either
package and/or documentation\&.
.PP
When proposing code changes, please provide \fIunified diffs\fR,
i\&.e the output of \fBdiff -u\fR\&.
.PP
Note further that \fIattachments\fR are strongly preferred over
inlined patches\&. Attachments can be made by going to the \fBEdit\fR
form of the ticket immediately after its creation, and then using the
left-most button in the secondary navigation bar\&.
.SH KEYWORDS
data analysis, mathematics, statistics
.SH CATEGORY
Mathematics