25package umontreal.ssj.probdist;
27import umontreal.ssj.util.Num;
41 private static final int STUDENT_N1 = 20;
42 private static final double STUDENT_X1 = 8.01;
43 private static final int STUDENT_KMAX = 200;
44 private static final double STUDENT_EPS = 0.5E-16;
58 public double cdf(
double x) {
62 public double barF(
double x) {
75 public static double cdf(
int n,
double x) {
78 if (x == Double.NEGATIVE_INFINITY)
80 if (x == Double.POSITIVE_INFINITY)
82 double b, y, z, z2, prec, v;
86 if (n <= STUDENT_N1 && x <= STUDENT_X1) {
88 y = x / Math.sqrt((
double) n);
90 for (k = n - 2; k >= 2; k -= 2)
91 z = 1.0 + z * (k - 1) / (k * b);
93 v = (1.0 + z * y / Math.sqrt(b)) / 2.0;
96 v = (0.5 + (Math.atan(y) + z * y / b) / Math.PI);
98 v = (Math.atan(-1.0 / y) + z * y / b) / Math.PI;
107 else if (x < STUDENT_X1) {
110 z2 = a * Math.log1p(x * x / n);
112 y = (((((64.0 * z2 + 788.0) * z2 + 9801.0) * z2 + 89775.0) * z2 + 543375.0) * z2 + 1788885.0) * z
113 / (210.0 * b * b * b);
114 y -= (((4.0 * z2 + 33.0) * z2 + 240.0) * z2 + 855.0) * z / (10.0 * b * b);
115 y += z + (z2 + 3.0) * z / b;
127 y *= 1.0 / (Math.sqrt(Math.PI * n) * Math.pow(b, (n + 1) / 2.0));
129 y *= 2.0 * Math.sqrt(n * b);
133 while (k < STUDENT_KMAX && prec > STUDENT_EPS) {
134 y *= (k - 1) / (k * b);
136 prec = Math.abs(z - z2);
140 if (k >= STUDENT_KMAX)
141 System.err.println(
"student: k >= STUDENT_KMAX");
143 return 1.0 - z / 2.0;
152 public static double barF(
int n,
double x) {
169 final double PI = Math.PI;
170 double a, b, c, d, e, p, t, x, y;
180 c = ((20700. / b * a - 98.) * a - 16.) * a + 96.36;
181 d = e * Math.sqrt(a * PI / 2.) * ((94.5 / (b + c) - 3.) / b + 1.);
182 y = Math.pow((d * p), (2.0 / e));
183 if (y > (a + 0.05)) {
190 c = c + 0.3 * (e - 4.5) * (x + 0.6);
192 c = (((0.05 * d * x - 5.) * x - 7.) * x - 2.) * x + b + c;
193 y = (((((0.4 * y + 6.3) * y + 36.) * y + 94.5) / c - y - 3.) / b + 1.) * x;
198 y = ((1. / (((e + 6.) / (e * y) - 0.089 * d - 0.822) * (e + 2.) * 3.) + 0.5 / (e + 4.)) * y - 1.) * (e + 1.)
202 t = Math.sqrt(e * y);
Extends the class ContinuousDistribution for the normal distribution (e.g., tjoh95a (page 80)).
static double inverseF01(double u)
Same as inverseF(0, 1, u).
static double barF01(double x)
Same as barF(0, 1, x).
static double cdf(int n, double x)
Returns the approximation of tken80a (page 96) of the Student -distribution function with degrees o...
double inverseF(double u)
Returns the inverse distribution function .
StudentDistQuick(int n)
Constructs a StudentDistQuick object with n degrees of freedom.
double cdf(double x)
Returns the distribution function .
static double inverseF(int n, double u)
Returns an approximation of , where is the Student -distribution function with degrees of freedom.
static double barF(int n, double x)
Computes the complementary distribution function .
double barF(double x)
Returns the complementary distribution function.
StudentDist(int n)
Constructs a StudentDist object with n degrees of freedom.
This class provides various constants and methods to compute numerical quantities such as factorials,...
static double gammaRatioHalf(double x)
Returns the value of the ratio of two gamma functions.