25package umontreal.ssj.probdist;
27import umontreal.ssj.util.Num;
45 private double lambda;
66 public double cdf(
double x) {
67 return cdf(lambda, x);
70 public double barF(
double x) {
71 return barF(lambda, x);
93 public static double density(
double lambda,
double x) {
95 throw new IllegalArgumentException(
"lambda <= 0");
96 return x < 0 ? 0 : lambda * Math.exp(-lambda * x);
102 public static double cdf(
double lambda,
double x) {
104 throw new IllegalArgumentException(
"lambda <= 0");
107 double y = lambda * x;
110 return -Math.expm1(-y);
116 public static double barF(
double lambda,
double x) {
118 throw new IllegalArgumentException(
"lambda <= 0");
121 if (lambda * x >= XBIGM)
123 return Math.exp(-lambda * x);
129 public static double inverseF(
double lambda,
double u) {
131 throw new IllegalArgumentException(
"lambda <= 0");
132 if (u < 0.0 || u > 1.0)
133 throw new IllegalArgumentException(
"u not in [0,1]");
135 return Double.POSITIVE_INFINITY;
138 return -Math.log1p(-u) / lambda;
154 public static double[]
getMLE(
double[] x,
int n) {
156 throw new IllegalArgumentException(
"n <= 0");
160 parameters =
new double[1];
161 for (
int i = 0; i < n; i++)
163 parameters[0] = (double) n / sum;
177 double parameters[] =
getMLE(x, n);
189 throw new IllegalArgumentException(
"lambda <= 0");
203 throw new IllegalArgumentException(
"lambda <= 0");
205 return (1 / (lambda * lambda));
216 throw new IllegalArgumentException(
"lambda <= 0");
233 throw new IllegalArgumentException(
"lambda <= 0");
234 this.lambda = lambda;
242 double[] retour = { lambda };
250 return getClass().getSimpleName() +
" : lambda = " + lambda;
Classes implementing continuous distributions should inherit from this base class.
double getLambda()
Returns the value of for this object.
double inverseF(double u)
Returns the inverse distribution function .
static double[] getMLE(double[] x, int n)
Estimates the rate parameter of the exponential distribution using the maximum likelihood method,...
double density(double x)
Returns , the density evaluated at .
double getStandardDeviation()
Returns the standard deviation.
double getVariance()
Returns the variance.
static double inverseF(double lambda, double u)
Computes the inverse distribution function.
ExponentialDist(double lambda)
Constructs an ExponentialDist object with rate parameter = lambda.
void setLambda(double lambda)
Sets the value of for this object.
static double density(double lambda, double x)
Computes the density function.
static double barF(double lambda, double x)
Computes the complementary distribution function.
static double getMean(double lambda)
Computes and returns the mean, , of the exponential distribution with rate parameter .
double getMean()
Returns the mean.
String toString()
Returns a String containing information about the current distribution.
static double getStandardDeviation(double lambda)
Computes and returns the standard deviation of the exponential distribution with rate parameter .
static double getVariance(double lambda)
Computes and returns the variance, , of the exponential distribution with rate parameter.
static double cdf(double lambda, double x)
Computes the distribution function.
double barF(double x)
Returns the complementary distribution function.
double cdf(double x)
Returns the distribution function .
ExponentialDist()
Constructs an ExponentialDist object with rate parameter = 1.
double[] getParams()
Return a table containing the parameters of the current distribution.
static ExponentialDist getInstanceFromMLE(double[] x, int n)
Creates a new instance of an exponential distribution with rate parameter.