25package umontreal.ssj.probdist;
27import umontreal.ssj.util.*;
28import umontreal.ssj.functions.MathFunction;
53 public Function(
int n,
double u) {
58 public double evaluate(
double x) {
75 public double cdf(
double x) {
79 public double barF(
double x) {
103 public static double density(
int n,
double x) {
105 throw new IllegalArgumentException(
"n <= 0");
107 if (x <= 1.0 / (12.0 * n) || x >= n / 3.0)
111 return 1.0 / Math.sqrt(x - 1.0 / 12.0);
113 if (x <= 0.002 || x > 3.95)
116 throw new UnsupportedOperationException(
"density not implemented.");
142 public static double cdf(
int n,
double x) {
144 throw new IllegalArgumentException(
"n <= 0");
151 return 2.0 * Math.sqrt(x - 1.0 / 12.0);
154 if (x <= 1.0 / (12.0 * n))
157 if (x <= (n + 3.0) / (12.0 * n * n)) {
159 + 0.5 * n * Math.log(Math.PI * (x - 1.0 / (12.0 * n)));
165 if (x > 3.95 || x >= n / 3.0)
171 double Cor, Res, arg;
172 double termX, termS, termJ;
177 final double A[] = { 1.0, 1.11803398875, 1.125, 1.12673477358, 1.1274116945, 1.12774323743, 1.1279296875,
178 1.12804477649, 1.12812074678, 1.12817350091 };
182 arg = termJ * termJ * termX;
186 }
while (!(termS < EPSILON || j > JMAX));
189 System.err.println(
"cramerVonMises: iterations have not converged");
190 Res /= Math.PI * Math.sqrt(x);
196 Cor = -0.0121763 + x * (2.56672 - 132.571 * x);
198 Cor = 0.108688 + x * (-7.14677 + 58.0662 * x);
200 Cor = -0.0539444 + x * (-2.22024 + x * (25.0407 - 64.9233 * x));
202 Cor = -0.251455 + x * (2.46087 + x * (-8.92836 + x * (14.0988 - x * (5.5204 + 4.61784 * x))));
204 Cor = 0.0782122 + x * (-0.519924 + x * (1.75148 + x * (-2.72035 + x * (1.94487 - 0.524911 * x))));
206 Cor = Math.exp(-0.244889 - 4.26506 * x);
220 public static double barF(
int n,
double x) {
221 return 1.0 -
cdf(n, x);
230 throw new IllegalArgumentException(
"n <= 0");
231 if (u < 0.0 || u > 1.0)
232 throw new IllegalArgumentException(
"u must be in [0,1]");
237 return 1.0 / (12.0 * n);
240 return 1.0 / 12.0 + 0.25 * u * u;
242 Function f =
new Function(n, u);
261 return (4.0 * n - 3.0) / (180.0 * n);
285 throw new IllegalArgumentException(
"n <= 0");
287 supportA = 1.0 / (12.0 * n);
295 double[] retour = { n };
303 return getClass().getSimpleName() +
" : n = " + n;
Classes implementing continuous distributions should inherit from this base class.
double getMean()
Returns the mean.
String toString()
Returns a String containing information about the current distribution.
static double cdf(int n, double x)
Computes the Cramér-von Mises distribution function with parameter.
double inverseF(double u)
Returns the inverse distribution function .
static double getStandardDeviation(int n)
Returns the standard deviation of the distribution with parameter.
int getN()
Returns the parameter of this object.
static double getMean(int n)
Returns the mean of the distribution with parameter .
void setN(int n)
Sets the parameter of this object.
static double getVariance(int n)
Returns the variance of the distribution with parameter .
double getStandardDeviation()
Returns the standard deviation.
static double inverseF(int n, double u)
Computes , where is the Cramér-von Mises distribution with parameter .
double barF(double x)
Returns the complementary distribution function.
double getVariance()
Returns the variance.
static double density(int n, double x)
Computes the density function for a Cramér-von Mises distribution with parameter .
CramerVonMisesDist(int n)
Constructs a Cramér-von Mises distribution for a sample of size .
double[] getParams()
Return an array containing the parameter of this object.
double density(double x)
Returns , the density evaluated at .
double cdf(double x)
Returns the distribution function .
static double barF(int n, double x)
Computes the complementary distribution function with parameter .
This class provides various constants and methods to compute numerical quantities such as factorials,...
static double lnGamma(double x)
Returns the natural logarithm of the gamma function evaluated at x.
static final double DBL_EPSILON
Difference between 1.0 and the smallest double greater than 1.0.
static double lnFactorial(int n)
Returns the value of , the natural logarithm of factorial .
static double besselK025(double x)
Returns the value of , where.
This class provides numerical methods to solve non-linear equations.
static double brentDekker(double a, double b, MathFunction f, double tol)
Computes a root of the function in f using the Brent-Dekker method.
This interface should be implemented by classes which represent univariate mathematical functions.