25package umontreal.ssj.probdist;
27import umontreal.ssj.util.*;
79 public double cdf(
double x) {
80 return cdf(mu, sigma, x);
83 public double barF(
double x) {
84 return barF(mu, sigma, x);
107 public static double density(
double mu,
double sigma,
double x) {
109 throw new IllegalArgumentException(
"sigma <= 0");
112 double diff = Math.log(x) - mu;
113 return Math.exp(-diff * diff / (2 * sigma * sigma)) / (Math.sqrt(2 * Math.PI) * sigma * x);
119 public static double cdf(
double mu,
double sigma,
double x) {
121 throw new IllegalArgumentException(
"sigma <= 0");
132 public static double barF(
double mu,
double sigma,
double x) {
134 throw new IllegalArgumentException(
"sigma <= 0");
144 public static double inverseF(
double mu,
double sigma,
double u) {
148 throw new IllegalArgumentException(
"sigma <= 0");
150 if (u > 1.0 || u < 0.0)
151 throw new IllegalArgumentException(
"u not in [0,1]");
154 return Double.POSITIVE_INFINITY;
163 return Double.POSITIVE_INFINITY;
186 public static double[]
getMLE(
double[] x,
int n) {
188 throw new IllegalArgumentException(
"n <= 0");
192 parameters =
new double[2];
194 for (
int i = 0; i < n; i++) {
196 sum += Math.log(x[i]);
200 parameters[0] = sum / n;
204 for (
int i = 0; i < n; i++) {
206 temp = Math.log(x[i]) - parameters[0];
208 temp = LN_EPS - parameters[0];
211 parameters[1] = Math.sqrt(sum / n);
226 double parameters[] =
getMLE(x, n);
236 public static double getMean(
double mu,
double sigma) {
238 throw new IllegalArgumentException(
"sigma <= 0");
240 return (Math.exp(mu + (sigma * sigma) / 2.0));
252 throw new IllegalArgumentException(
"sigma <= 0");
254 return (Math.exp(2.0 * mu + sigma * sigma) * (Math.exp(sigma * sigma) - 1.0));
286 throw new IllegalArgumentException(
"sigma <= 0");
297 double[] retour = { mu, sigma };
305 return getClass().getSimpleName() +
" : mu = " + mu +
", sigma = " + sigma;
Classes implementing continuous distributions should inherit from this base class.
double barF(double x)
Returns the complementary distribution function.
double density(double x)
Returns , the density evaluated at .
double cdf(double x)
Returns the distribution function .
double[] getParams()
Returns a table containing the parameters of the current distribution, in the order: [ ,...
static double inverseF(double mu, double sigma, double u)
Computes the inverse of the lognormal distribution function, using NormalDist.inverseF01.
double getStandardDeviation()
Returns the standard deviation.
static double getMean(double mu, double sigma)
Computes and returns the mean of the lognormal distribution with parameters and.
static double barF(double mu, double sigma, double x)
Computes the lognormal complementary distribution function.
static double[] getMLE(double[] x, int n)
Estimates the parameters of the lognormal distribution using the maximum likelihood method,...
LognormalDist(double mu, double sigma)
Constructs a LognormalDist object with parameters = mu and = sigma.
static double getVariance(double mu, double sigma)
Computes and returns the variance of the lognormal distribution with parameters and .
static double cdf(double mu, double sigma, double x)
Computes the lognormal distribution function, using NormalDist.cdf01.
void setParams(double mu, double sigma)
Sets the parameters and of this object.
double getMu()
Returns the parameter of this object.
double getMean()
Returns the mean.
double inverseF(double u)
Returns the inverse distribution function .
static LognormalDist getInstanceFromMLE(double[] x, int n)
Creates a new instance of a lognormal distribution with parameters.
double getSigma()
Returns the parameter of this object.
LognormalDist()
Constructs a LognormalDist object with default parameters and .
static double density(double mu, double sigma, double x)
Computes the lognormal density function in ( flognormal ).
double getVariance()
Returns the variance.
static double getStandardDeviation(double mu, double sigma)
Computes and returns the standard deviation of the lognormal distribution with parameters and .
String toString()
Returns a String containing information about the current distribution.
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 cdf01(double x)
Same as cdf(0, 1, x).
static double barF01(double x)
Same as barF(0, 1, x).
This class provides various constants and methods to compute numerical quantities such as factorials,...
static final double LN_DBL_MIN
Natural logarithm of DBL_MIN.
static final double DBL_EPSILON
Difference between 1.0 and the smallest double greater than 1.0.
static final int DBL_MAX_EXP
Largest int such that is representable (approximately) as a double.
static final double LN2
The values of .