25package umontreal.ssj.probdist;
27import umontreal.ssj.probdist.NormalDist;
28import umontreal.ssj.util.*;
29import umontreal.ssj.functions.MathFunction;
56 protected double lambda;
60 protected double lambda;
63 public Function(
double mu,
double lambda,
double u) {
69 public double evaluate(
double x) {
70 return u -
cdf(mu, lambda, x);
87 public double cdf(
double x) {
88 return cdf(mu, lambda, x);
91 public double barF(
double x) {
92 return barF(mu, lambda, x);
118 public static double density(
double mu,
double lambda,
double x) {
120 throw new IllegalArgumentException(
"mu <= 0");
122 throw new IllegalArgumentException(
"lambda <= 0");
126 double sqrtX = Math.sqrt(x);
128 return (Math.sqrt(lambda / (2 * Math.PI)) / (sqrtX * sqrtX * sqrtX)
129 * Math.exp(-lambda * (x - 2 * mu + (mu * mu / x)) / (2 * mu * mu)));
138 public static double cdf(
double mu,
double lambda,
double x) {
140 throw new IllegalArgumentException(
"mu <= 0");
142 throw new IllegalArgumentException(
"lambda <= 0");
145 double temp = Math.sqrt(lambda / x);
146 double z = temp * (x / mu - 1.0);
147 double w = temp * (x / mu + 1.0);
158 public static double barF(
double mu,
double lambda,
double x) {
159 return 1.0 -
cdf(mu, lambda, x);
166 public static double inverseF(
double mu,
double lambda,
double u) {
168 throw new IllegalArgumentException(
"mu <= 0");
170 throw new IllegalArgumentException(
"lambda <= 0");
171 if (u < 0.0 || u > 1.0)
172 throw new IllegalArgumentException(
"u must be in [0,1]");
174 return Double.POSITIVE_INFINITY;
178 Function f =
new Function(mu, lambda, u);
184 double v =
cdf(mu, lambda, x);
188 v =
cdf(mu, lambda, x);
212 public static double[]
getMLE(
double[] x,
int n) {
214 throw new IllegalArgumentException(
"n <= 0");
217 parameters =
new double[2];
219 for (
int i = 0; i < n; i++) {
222 parameters[0] = sum / (double) n;
225 for (
int i = 0; i < n; i++) {
226 sum += ((1.0 / (double) x[i]) - (1.0 / parameters[0]));
228 parameters[1] = (double) n / (
double) sum;
243 double parameters[] =
getMLE(x, n);
253 public static double getMean(
double mu,
double lambda) {
255 throw new IllegalArgumentException(
"mu <= 0");
257 throw new IllegalArgumentException(
"lambda <= 0");
271 throw new IllegalArgumentException(
"mu <= 0");
273 throw new IllegalArgumentException(
"lambda <= 0");
275 return (mu * mu * mu / lambda);
307 throw new IllegalArgumentException(
"mu <= 0");
309 throw new IllegalArgumentException(
"lambda <= 0");
312 this.lambda = lambda;
321 double[] retour = { mu, lambda };
329 return getClass().getSimpleName() +
" : mu = " + mu +
", lambda = " + lambda;
Classes implementing continuous distributions should inherit from this base class.
static double getMean(double mu, double lambda)
Returns the mean of the inverse gaussian distribution with parameters and .
double getLambda()
Returns the parameter of this object.
static InverseGaussianDist getInstanceFromMLE(double[] x, int n)
Creates a new instance of an inverse gaussian distribution with parameters and estimated using the ...
static double getStandardDeviation(double mu, double lambda)
Computes and returns the standard deviation of the inverse gaussian distribution with parameters and...
String toString()
Returns a String containing information about the current distribution.
double getMean()
Returns the mean.
double density(double x)
Returns , the density evaluated at .
static double[] getMLE(double[] x, int n)
Estimates the parameters of the inverse gaussian distribution using the maximum likelihood method,...
static double getVariance(double mu, double lambda)
Computes and returns the variance of the inverse gaussian distribution with parameters and .
static double cdf(double mu, double lambda, double x)
Computes the distribution function ( FInverseGaussian ) of the inverse gaussian distribution with par...
double barF(double x)
Returns the complementary distribution function.
static double inverseF(double mu, double lambda, double u)
Computes the inverse of the inverse gaussian distribution with parameters and .
static double barF(double mu, double lambda, double x)
Computes the complementary distribution function of the inverse gaussian distribution with parameters...
double inverseF(double u)
Returns the inverse distribution function .
static double density(double mu, double lambda, double x)
Computes the density function ( fInverseGaussian ) for the inverse gaussian distribution with paramet...
double[] getParams()
Return a table containing the parameters of the current distribution.
double getVariance()
Returns the variance.
double cdf(double x)
Returns the distribution function .
InverseGaussianDist(double mu, double lambda)
Constructs the inverse Gaussian distribution with parameters.
void setParams(double mu, double lambda)
Sets the parameters and of this object.
double getMu()
Returns the parameter of this object.
double getStandardDeviation()
Returns the standard deviation.
Extends the class ContinuousDistribution for the normal distribution (e.g., tjoh95a (page 80)).
static double cdf01(double x)
Same as cdf(0, 1, x).
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.