SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
GofStat.java
1/*
2 * Class: GofStat
3 * Description: Goodness-of-fit test statistics
4 * Environment: Java
5 * Software: SSJ
6 * Copyright (C) 2001 Pierre L'Ecuyer and Universite de Montreal
7 * Organization: DIRO, Universite de Montreal
8 * @author
9 * @since
10 *
11 *
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 *
24 */
25package umontreal.ssj.gof;
26
27import cern.colt.list.*;
28import umontreal.ssj.util.*;
29import umontreal.ssj.probdist.*;
30import java.util.Arrays;
31
46public class GofStat {
47 private GofStat() {
48 }
49
53
54 // Used in discontinuous distributions
55 private static double EPSILOND = 1.0E-15;
56
70 public static DoubleArrayList unifTransform(DoubleArrayList data, ContinuousDistribution dist) {
71 double[] v = data.elements();
72 int n = data.size();
73
74 double[] u = new double[n];
75 for (int i = 0; i < n; i++)
76 u[i] = dist.cdf(v[i]);
77 return new DoubleArrayList(u);
78 }
79
95 public static DoubleArrayList unifTransform(DoubleArrayList data, DiscreteDistribution dist) {
96 double[] v = data.elements();
97 int n = data.size();
98
99 double[] u = new double[n];
100 for (int i = 0; i < n; i++)
101 u[i] = dist.cdf((int) v[i]);
102 return new DoubleArrayList(u);
103 }
104
126 public static void diff(IntArrayList sortedData, IntArrayList spacings, int n1, int n2, int a, int b) {
127 if (n1 < 0 || n2 < 0 || n1 >= n2 || n2 >= sortedData.size())
128 throw new IllegalArgumentException("n1 and n2 not valid.");
129 int[] u = sortedData.elements();
130 int n = sortedData.size();
131 if (spacings.size() <= (n2 + 2))
132 spacings.setSize(n2 + 2);
133 int[] d = spacings.elements();
134
135 d[n1] = u[n1] - a;
136 for (int i = n1 + 1; i <= n2; i++)
137 d[i] = u[i] - u[i - 1];
138 d[n2 + 1] = b - u[n2];
139 }
140
155 public static void diff(DoubleArrayList sortedData, DoubleArrayList spacings, int n1, int n2, double a, double b) {
156
157 if (n1 < 0 || n2 < 0 || n1 >= n2 || n2 >= sortedData.size())
158 throw new IllegalArgumentException("n1 and n2 not valid.");
159 double[] u = sortedData.elements();
160 int n = sortedData.size();
161 if (spacings.size() <= (n2 + 2))
162 spacings.setSize(n2 + 2);
163 double[] d = spacings.elements();
164
165 d[n1] = u[n1] - a;
166 for (int i = n1 + 1; i <= n2; i++)
167 d[i] = u[i] - u[i - 1];
168 d[n2 + 1] = b - u[n2];
169 }
170
213 public static void iterateSpacings(DoubleArrayList data, DoubleArrayList spacings) {
214 if (spacings.size() < (data.size() + 1))
215 throw new IllegalArgumentException("Invalid array sizes.");
216 double[] v = data.elements();
217 spacings.quickSortFromTo(0, data.size());
218 double[] s = spacings.elements();
219 int n = data.size();
220
221 for (int i = 0; i < n; i++)
222 s[n - i] = (i + 1) * (s[n - i] - s[n - i - 1]);
223 s[0] = (n + 1) * s[0];
224 v[0] = s[0];
225 for (int i = 1; i < n; i++)
226 v[i] = v[i - 1] + s[i];
227 }
228
252 public static void powerRatios(DoubleArrayList sortedData) {
253
254 double[] u = sortedData.elements();
255 int n = sortedData.size();
256
257 for (int i = 0; i < (n - 1); i++) {
258 if (u[i + 1] == 0.0 || u[i + 1] == -0.0)
259 u[i] = 1.0;
260 else
261 u[i] = Math.pow(u[i] / u[i + 1], (double) i + 1);
262 }
263
264 u[n - 1] = Math.pow(u[n - 1], (double) n);
265 sortedData.quickSortFromTo(0, sortedData.size() - 1);
266 }
267
271
275
297 public static class OutcomeCategoriesChi2 {
298
302 public int nbCategories;
303
307 public int smin;
308
312 public int smax;
313
317 public double[] nbExp;
318
322 public int[] loc;
323
334 public OutcomeCategoriesChi2(double[] nbExp) {
335 this.nbExp = nbExp;
336 smin = 0;
337 smax = nbExp.length - 1;
338 nbCategories = nbExp.length;
339 loc = new int[nbExp.length];
340 for (int i = 0; i < nbExp.length; i++)
341 loc[i] = i;
342 }
343
358 public OutcomeCategoriesChi2(double[] nbExp, int smin, int smax) {
359 this.nbExp = nbExp;
360 this.smin = smin;
361 this.smax = smax;
362 nbCategories = smax - smin + 1;
363 loc = new int[nbExp.length];
364 for (int i = 0; i < smin; i++)
365 loc[i] = smin;
366 for (int i = smin; i < smax; i++)
367 loc[i] = i;
368 for (int i = smax; i < nbExp.length; i++)
369 loc[i] = smax;
370 }
371
382 public OutcomeCategoriesChi2(double[] nbExp, int[] loc, int smin, int smax, int nbCat) {
383 this.nbExp = nbExp;
384 this.smin = smin;
385 this.smax = smax;
386 this.nbCategories = nbCat;
387 this.loc = loc;
388 }
389
397 public void regroupCategories(double minExp) {
398 int s0 = 0, j;
399 double somme;
400
401 nbCategories = 0;
402 int s = smin;
403 while (s <= smax) {
404 /*
405 * Merge categories to ensure that the number expected in each category is >=
406 * minExp.
407 */
408 if (nbExp[s] < minExp) {
409 s0 = s;
410 somme = nbExp[s];
411 while (somme < minExp && s < smax) {
412 nbExp[s] = 0.0;
413 ++s;
414 somme += nbExp[s];
415 }
416 nbExp[s] = somme;
417 for (j = s0; j <= s; j++)
418 loc[j] = s;
419
420 } else
421 loc[s] = s;
422
423 ++nbCategories;
424 ++s;
425 }
426 smin = loc[smin];
427
428 // Special case: the last category, if nbExp < minExp
429 if (nbExp[smax] < minExp) {
430 if (s0 > smin)
431 --s0;
432 nbExp[s0] += nbExp[smax];
433 nbExp[smax] = 0.0;
434 --nbCategories;
435 for (j = s0 + 1; j <= smax; j++)
436 loc[j] = s0;
437 smax = s0;
438 }
439 if (nbCategories <= 1)
440 throw new IllegalStateException("nbCategories < 2");
441 }
442
448 public String toString() {
449 int s, s0;
450 double somme;
451 final double EPSILON = 5.0E-16;
452 StringBuffer sb = new StringBuffer();
453 sb.append("-----------------------------------------------" + PrintfFormat.NEWLINE);
454 if (nbExp[smin] < EPSILON)
455 sb.append("Only expected numbers larger than " + PrintfFormat.g(6, 1, EPSILON) + " are printed"
457 sb.append("Number of categories: " + PrintfFormat.d(4, nbCategories) + PrintfFormat.NEWLINE
458 + "Expected numbers per category:" + PrintfFormat.NEWLINE + PrintfFormat.NEWLINE
459 + "Category s nbExp[s]" + PrintfFormat.NEWLINE);
460
461 // Do not print values < EPSILON
462 s = smin;
463 while (nbExp[s] < EPSILON)
464 s++;
465 int s1 = s;
466
467 s = smax;
468 while (nbExp[s] < EPSILON)
469 s--;
470 int s2 = s;
471
472 somme = 0.0;
473 for (s = s1; s <= s2; s++)
474 if (loc[s] == s) {
475 somme += nbExp[s];
476 sb.append(PrintfFormat.d(4, s) + " " + PrintfFormat.f(18, 4, nbExp[s]) + PrintfFormat.NEWLINE);
477 }
478 sb.append(PrintfFormat.NEWLINE + "Total expected number = " + PrintfFormat.f(18, 2, somme)
480 + " Category s loc[s]" + PrintfFormat.NEWLINE);
481 for (s = smin; s <= smax; s++) {
482 if ((s == smin) && (s > 0))
483 sb.append("<= ");
484 else if ((s == smax) && (s < loc.length - 1))
485 sb.append(">= ");
486 else
487 sb.append(" ");
488 sb.append(PrintfFormat.d(4, s) + " " + PrintfFormat.d(12, loc[s]) + PrintfFormat.NEWLINE);
489 }
490
492 return sb.toString();
493 }
494 }
495
499
503
524 public static double chi2(double[] nbExp, int[] count, int smin, int smax) {
525 double diff, khi = 0.0;
526
527 for (int s = smin; s <= smax; s++) {
528 if (nbExp[s] <= 0.0) {
529 if (count[s] != 0)
530 throw new IllegalArgumentException("nbExp[s] = 0 and count[s] > 0");
531 } else {
532 diff = count[s] - nbExp[s];
533 khi += diff * diff / nbExp[s];
534 }
535 }
536 return khi;
537 }
538
551 public static double chi2(OutcomeCategoriesChi2 cat, int[] count) {
552 int[] newcount = new int[1 + cat.smax];
553 for (int s = cat.smin; s <= cat.smax; s++) {
554 newcount[cat.loc[s]] += count[s];
555 }
556
557 double diff, khi = 0.0;
558
559 for (int s = cat.smin; s <= cat.smax; s++) {
560 if (cat.nbExp[s] > 0.0) {
561 diff = newcount[s] - cat.nbExp[s];
562 khi += diff * diff / cat.nbExp[s];
563 }
564 }
565 newcount = null;
566 return khi;
567 }
568
609 public static double chi2(IntArrayList data, DiscreteDistributionInt dist, int smin, int smax, double minExp,
610 int[] numCat) {
611 int i;
612 int n = data.size();
613
614 // Find the first non-negligible probability term and fix
615 // the real smin. The linear search starts from the given smin.
616 i = smin;
617 while (dist.prob(i) * n <= DiscreteDistributionInt.EPSILON)
618 i++;
619 smin = i--;
620
621 // smax > smin is required
622 while (smax <= smin)
623 smax = 2 * smax + 1;
624
625 // Allocate and fill the array of expected observations
626 // Each category s corresponds to a value s for which p(s)>0.
627 double[] nbExp = new double[smax + 1];
628 do {
629 i++;
630 if (i > smax) {
631 smax *= 2;
632 double[] newNbExp = new double[smax + 1];
633 System.arraycopy(nbExp, smin, newNbExp, smin, nbExp.length - smin);
634 nbExp = newNbExp;
635 }
636 nbExp[i] = dist.prob(i) * n;
637 } while (nbExp[i] > DiscreteDistributionInt.EPSILON);
638 smax = i - 1;
639
640 // Regroup the expected observations intervals
641 // satisfying np(s)>=minExp
642 OutcomeCategoriesChi2 cat = new OutcomeCategoriesChi2(nbExp, smin, smax);
643 cat.regroupCategories(minExp);
644 if (numCat != null)
645 numCat[0] = cat.nbCategories;
646
647 // Count the number of observations in each categories.
648 int[] count = new int[cat.smax + 1];
649 for (i = 0; i < count.length; i++)
650 count[i] = 0;
651 for (i = 0; i < n; i++) {
652 int s = data.get(i);
653 while (cat.loc[s] != s)
654 s = cat.loc[s];
655 count[s]++;
656 }
657
658 // Perform the chi-square test
659 return chi2(cat.nbExp, count, cat.smin, cat.smax);
660 }
661
673 public static double chi2Equal(double nbExp, int[] count, int smin, int smax) {
674
675 double diff, khi = 0.0;
676 for (int s = smin; s <= smax; s++) {
677 diff = count[s] - nbExp;
678 khi += diff * diff;
679 }
680 return khi / nbExp;
681 }
682
698 public static double chi2Equal(DoubleArrayList data, double minExp) {
699 int n = data.size();
700 if (n < (int) Math.ceil(minExp))
701 throw new IllegalArgumentException("Not enough observations");
702 double p = minExp / n;
703 int m = (int) Math.ceil(1.0 / p);
704 // to avoid an exception when data[i] = 1/p, reserve one element more
705 int[] count = new int[m + 1];
706 for (int i = 0; i < n; i++) {
707 int j = (int) Math.floor(data.get(i) / p);
708 count[j]++;
709 }
710 // put the elements in count[m] where they belong: in count[m-1]
711 count[m - 1] += count[m];
712 return chi2Equal(minExp, count, 0, m - 1);
713 }
714
721 public static double chi2Equal(DoubleArrayList data) {
722 return chi2Equal(data, 10.0);
723 }
724
738 public static int scan(DoubleArrayList sortedData, double d) {
739
740 double[] u = sortedData.elements();
741 int n = sortedData.size();
742
743 int m = 1, j = 0, i = -1;
744 double High = 0.0;
745
746 while (j < (n - 1) && High < 1.0) {
747 ++i;
748
749 High = u[i] + d;
750 while (j < n && u[j] < High)
751 ++j;
752 // j is now the index of the first obs. to the right of High.
753 if (j - i > m)
754 m = j - i;
755 }
756 return m;
757 }
758
771 public static double cramerVonMises(DoubleArrayList sortedData) {
772 double w, w2;
773 double[] u = sortedData.elements();
774 int n = sortedData.size();
775
776 if (n <= 0) {
777 System.err.println("cramerVonMises: n <= 0");
778 return 0.0;
779 }
780
781 w2 = 1.0 / (12 * n);
782 for (int i = 0; i < n; i++) {
783 w = u[i] - (i + 0.5) / n;
784 w2 += w * w;
785 }
786 return w2;
787 }
788
805 public static double watsonG(DoubleArrayList sortedData) {
806 double[] u = sortedData.elements();
807 int n = sortedData.size();
808 double sumZ;
809 double d2;
810 double dp, g;
811 double unSurN = 1.0 / n;
812
813 if (n <= 0) {
814 System.err.println("watsonG: n <= 0");
815 return 0.0;
816 }
817
818 // degenerate case n = 1
819 if (n == 1)
820 return 0.0;
821
822 // We assume that u is already sorted.
823 dp = sumZ = 0.0;
824 for (int i = 0; i < n; i++) {
825 d2 = (i + 1) * unSurN - u[i];
826 if (d2 > dp)
827 dp = d2;
828 sumZ += u[i];
829 }
830 sumZ = sumZ * unSurN - 0.5;
831 g = Math.sqrt((double) n) * (dp + sumZ);
832 return g;
833 }
834
850 public static double watsonU(DoubleArrayList sortedData) {
851 double sumZ, w, w2, u2;
852 double[] u = sortedData.elements();
853 int n = sortedData.size();
854
855 if (n <= 0) {
856 System.err.println("watsonU: n <= 0");
857 return 0.0;
858 }
859
860 // degenerate case n = 1
861 if (n == 1)
862 return 1.0 / 12.0;
863
864 sumZ = 0.0;
865 w2 = 1.0 / (12 * n);
866 for (int i = 0; i < n; i++) {
867 sumZ += u[i];
868 w = u[i] - (i + 0.5) / n;
869 w2 += w * w;
870 }
871 sumZ = sumZ / n - 0.5;
872 u2 = w2 - sumZ * sumZ * n;
873 return u2;
874 }
875
880 public static double EPSILONAD = Num.DBL_EPSILON / 2;
881
890 public static double andersonDarling(DoubleArrayList sortedData) {
891 double[] v = sortedData.elements();
892 return andersonDarling(v);
893 }
894
913 public static double andersonDarling(double[] sortedData) {
914 double u1;
915 double u, a2;
916 int n = sortedData.length;
917
918 if (n <= 0) {
919 System.err.println("andersonDarling: n <= 0");
920 return 0.0;
921 }
922
923 a2 = 0.0;
924 for (int i = 0; i < n; i++) {
925 u = sortedData[i];
926 u1 = 1.0 - u;
927 if (u < EPSILONAD)
928 u = EPSILONAD;
929 else if (u1 < EPSILONAD)
930 u1 = EPSILONAD;
931 a2 += (2 * i + 1) * Math.log(u) + (1 + 2 * (n - i - 1)) * Math.log(u1);
932 }
933 a2 = -n - a2 / n;
934 return a2;
935 }
936
947 public static double[] andersonDarling(double[] data, ContinuousDistribution dist) {
948 int n = data.length;
949 double[] U = new double[n];
950 for (int i = 0; i < n; i++) {
951 U[i] = dist.cdf(data[i]);
952 }
953
954 Arrays.sort(U);
955 double x = GofStat.andersonDarling(U);
956 double v = AndersonDarlingDistQuick.barF(n, x);
957 double[] res = { x, v };
958 return res;
959 }
960
970 public static double[] kolmogorovSmirnov(double[] sortedData) {
971 DoubleArrayList v = new DoubleArrayList(sortedData);
972 return kolmogorovSmirnov(v);
973 }
974
993 public static double[] kolmogorovSmirnov(DoubleArrayList sortedData) {
994 double[] ret = new double[3];
995 int n = sortedData.size();
996
997 if (n <= 0) {
998 ret[0] = ret[1] = ret[2] = 0.0;
999 System.err.println("kolmogorovSmirnov: n <= 0");
1000 return ret;
1001 }
1002
1003 double[] retjo = kolmogorovSmirnovJumpOne(sortedData, 0.0);
1004 ret[0] = retjo[0];
1005 ret[1] = retjo[1];
1006 if (ret[1] > ret[0])
1007 ret[2] = ret[1];
1008 else
1009 ret[2] = ret[0];
1010
1011 return ret;
1012 }
1013
1029 public static void kolmogorovSmirnov(double[] data, ContinuousDistribution dist, double[] sval, double[] pval) {
1030 int n = data.length;
1031 double[] T = new double[n];
1032 for (int i = 0; i < n; i++) {
1033 T[i] = dist.cdf(data[i]);
1034 }
1035
1036 Arrays.sort(T);
1037 double[] statks = GofStat.kolmogorovSmirnov(T);
1038 for (int i = 0; i < 3; i++) {
1039 sval[i] = statks[i];
1040 }
1041 pval[2] = KolmogorovSmirnovDistQuick.barF(n, sval[2]);
1042 pval[1] = KolmogorovSmirnovPlusDist.barF(n, sval[1]);
1043 pval[0] = KolmogorovSmirnovPlusDist.barF(n, sval[0]);
1044 }
1045
1058 public static double[] kolmogorovSmirnovJumpOne(DoubleArrayList sortedData, double a) {
1059 /*
1060 * Statistics KS+ and KS-. Case with 1 jump at a, near the lower tail of the
1061 * distribution.
1062 */
1063
1064 double[] u = sortedData.elements();
1065 int n = sortedData.size();
1066 int j, i;
1067 double d2, d1, unSurN;
1068 double[] ret = new double[2];
1069
1070 if (n <= 0) {
1071 ret[0] = ret[1] = 0.0;
1072 System.err.println("kolmogorovSmirnovJumpOne: n <= 0");
1073 return ret;
1074 }
1075
1076 ret[0] = 0.0;
1077 ret[1] = 0.0;
1078 unSurN = 1.0 / n;
1079 j = 0;
1080
1081 while (j < n && u[j] <= a + EPSILOND)
1082 ++j;
1083
1084 for (i = j - 1; i < n; i++) {
1085 if (i >= 0) {
1086 d1 = (i + 1) * unSurN - u[i];
1087 if (d1 > ret[0])
1088 ret[0] = d1;
1089 }
1090 if (i >= j) {
1091 d2 = u[i] - i * unSurN;
1092 if (d2 > ret[1])
1093 ret[1] = d2;
1094 }
1095 }
1096 return ret;
1097 }
1098
1116 public static double pDisc(double pL, double pR) {
1117 double p;
1118
1119 if (pR < pL)
1120 p = pR;
1121 else if (pL > 0.5)
1122 p = 0.5;
1123 else
1124 p = 1.0 - pL;
1125 // Note: si p est tres proche de 1, on perd toute la precision ici!
1126 // Note2: je ne pense pas que cela puisse se produire a cause des if (RS)
1127 return p;
1128 }
1129}
1130
This class helps managing the partitions of possible outcomes into categories for applying chi-square...
Definition GofStat.java:297
int smax
Maximum index for valid expected numbers in the array nbExp.
Definition GofStat.java:312
int smin
Minimum index for valid expected numbers in the array nbExp.
Definition GofStat.java:307
int nbCategories
Total number of categories.
Definition GofStat.java:302
void regroupCategories(double minExp)
Regroup categories as explained earlier, so that the expected number of observations in each category...
Definition GofStat.java:397
OutcomeCategoriesChi2(double[] nbExp, int[] loc, int smin, int smax, int nbCat)
Constructs an OutcomeCategoriesChi2 object.
Definition GofStat.java:382
OutcomeCategoriesChi2(double[] nbExp)
Constructs an OutcomeCategoriesChi2 object using the array nbExp for the number of expected observati...
Definition GofStat.java:334
double[] nbExp
Expected number of observations for each category.
Definition GofStat.java:317
int[] loc
loc[i] gives the relocation of the category i in the nbExp array.
Definition GofStat.java:322
OutcomeCategoriesChi2(double[] nbExp, int smin, int smax)
Constructs an OutcomeCategoriesChi2 object using the given nbExp expected observations array.
Definition GofStat.java:358
String toString()
Provides a report on the categories.
Definition GofStat.java:448
static double andersonDarling(DoubleArrayList sortedData)
Computes and returns the Anderson-Darling statistic (see method andersonDarling(double[]) ).
Definition GofStat.java:890
static double[] kolmogorovSmirnov(double[] sortedData)
Computes the Kolmogorov-Smirnov (KS) test statistics ,.
Definition GofStat.java:970
static double cramerVonMises(DoubleArrayList sortedData)
Computes and returns the Cramér-von Mises statistic (see.
Definition GofStat.java:771
static DoubleArrayList unifTransform(DoubleArrayList data, ContinuousDistribution dist)
Applies the probability integral transformation for.
Definition GofStat.java:70
static double chi2Equal(DoubleArrayList data)
Equivalent to chi2Equal (data, 10).
Definition GofStat.java:721
static DoubleArrayList unifTransform(DoubleArrayList data, DiscreteDistribution dist)
Applies the transformation for , where is a discrete distribution function, and returns the result ...
Definition GofStat.java:95
static double watsonG(DoubleArrayList sortedData)
Computes and returns the Watson statistic (see.
Definition GofStat.java:805
static void kolmogorovSmirnov(double[] data, ContinuousDistribution dist, double[] sval, double[] pval)
Computes the KolmogorovSmirnov (KS) test statistics and their.
static double chi2Equal(double nbExp, int[] count, int smin, int smax)
Similar to chi2(double[],int[],int,int), except that the expected number of observations per category...
Definition GofStat.java:673
static double[] andersonDarling(double[] data, ContinuousDistribution dist)
Computes the Anderson-Darling statistic and the corresponding -value .
Definition GofStat.java:947
static void diff(DoubleArrayList sortedData, DoubleArrayList spacings, int n1, int n2, double a, double b)
Same as method diff(IntArrayList,IntArrayList,int,int,int,int), but for the continuous case.
Definition GofStat.java:155
static double chi2Equal(DoubleArrayList data, double minExp)
Computes the chi-square statistic for a continuous distribution.
Definition GofStat.java:698
static void iterateSpacings(DoubleArrayList data, DoubleArrayList spacings)
Applies one iteration of the iterated spacings transformation.
Definition GofStat.java:213
static double andersonDarling(double[] sortedData)
Computes and returns the Anderson-Darling statistic (see.
Definition GofStat.java:913
static int scan(DoubleArrayList sortedData, double d)
Computes and returns the scan statistic , defined in ( scan ).
Definition GofStat.java:738
static double[] kolmogorovSmirnovJumpOne(DoubleArrayList sortedData, double a)
Compute the KS statistics and defined in the description of the method FDist.kolmogorovSmirnovPlusJ...
static double[] kolmogorovSmirnov(DoubleArrayList sortedData)
Computes the Kolmogorov-Smirnov (KS) test statistics ,.
Definition GofStat.java:993
static void powerRatios(DoubleArrayList sortedData)
Applies the power ratios transformation described in section 8.4 of Stephens tste86a .
Definition GofStat.java:252
static double watsonU(DoubleArrayList sortedData)
Computes and returns the Watson statistic (see.
Definition GofStat.java:850
static double chi2(double[] nbExp, int[] count, int smin, int smax)
Computes and returns the chi-square statistic for the observations.
Definition GofStat.java:524
static double pDisc(double pL, double pR)
Computes a variant of the -value whenever a test statistic has a discrete probability distribution.
static double EPSILONAD
Used by andersonDarling(DoubleArrayList).
Definition GofStat.java:880
static double chi2(IntArrayList data, DiscreteDistributionInt dist, int smin, int smax, double minExp, int[] numCat)
Computes and returns the chi-square statistic for the observations stored in data,...
Definition GofStat.java:609
static void diff(IntArrayList sortedData, IntArrayList spacings, int n1, int n2, int a, int b)
Assumes that the real-valued observations contained in sortedData are already sorted in increasing o...
Definition GofStat.java:126
static double chi2(OutcomeCategoriesChi2 cat, int[] count)
Computes and returns the chi-square statistic for the observations.
Definition GofStat.java:551
Extends the class AndersonDarlingDist for the Anderson–Darling distribution (see tand52a,...
double barF(double x)
Returns the complementary distribution function.
Classes implementing continuous distributions should inherit from this base class.
Classes implementing discrete distributions over the integers should inherit from this class.
abstract double prob(int x)
Returns , the probability of .
static double EPSILON
Environment variable that determines what probability terms can be considered as negligible when buil...
This class implements discrete distributions over a finite set of real numbers (also over integers as...
Extends the class KolmogorovSmirnovDist for the Kolmogorov–Smirnov distribution.
double barF(double x)
Returns the complementary distribution function.
Extends the class ContinuousDistribution for the Kolmogorov–Smirnov+ distribution (see tdar60a,...
double barF(double x)
Returns the complementary distribution function.
static final double DBL_EPSILON
Difference between 1.0 and the smallest double greater than 1.0.
Definition Num.java:90
This class acts like a StringBuffer which defines new types of append methods.
static String d(long x)
Same as d(0, 1, x).
static String f(double x)
Same as f(0, 6, x).
static final String NEWLINE
End-of-line symbol or line separator.
static String g(double x)
Same as g(0, 6, x).
double cdf(double x)
Returns the distribution function .