25package umontreal.ssj.probdist;
27import umontreal.ssj.util.Num;
66 throw new IllegalArgumentException(
"beta <= 0");
76 public double cdf(
double x) {
77 return cdf(mu, beta, x);
80 public double barF(
double x) {
81 return barF(mu, beta, x);
103 public static double density(
double mu,
double beta,
double x) {
105 throw new IllegalArgumentException(
"beta <= 0");
106 return Math.exp(-Math.abs(x - mu) / beta) / (2.0 * beta);
112 public static double cdf(
double mu,
double beta,
double x) {
114 return Math.exp((x - mu) / beta) / 2.0;
116 return 1.0 - Math.exp((mu - x) / beta) / 2.0;
122 public static double barF(
double mu,
double beta,
double x) {
124 return 1.0 - Math.exp((x - mu) / beta) / 2.0;
126 return Math.exp((mu - x) / beta) / 2.0;
137 public static double inverseF(
double mu,
double beta,
double u) {
139 if (u < 0.0 || u > 1.0)
140 throw new IllegalArgumentException(
"u should be in [0,1]");
142 return Double.NEGATIVE_INFINITY;
144 return Double.POSITIVE_INFINITY;
146 double x = (u > 0.5) ? -Math.log(2. - 2 * u) : Math.log(2 * u);
147 return mu + beta * x;
166 public static double[]
getMLE(
double[] x,
int n) {
168 throw new IllegalArgumentException(
"n <= 0");
171 parameters =
new double[2];
176 for (
int i = 0; i < n; i++)
177 sum += Math.abs(x[i] - parameters[0]);
178 parameters[1] = sum / (double) n;
192 double parameters[] =
getMLE(x, n);
193 return new LaplaceDist(parameters[0], parameters[1]);
202 public static double getMean(
double mu,
double beta) {
204 throw new IllegalArgumentException(
"beta <= 0");
218 throw new IllegalArgumentException(
"beta <= 0");
220 return (2.0 * beta * beta);
231 throw new IllegalArgumentException(
"beta <= 0");
255 double[] retour = { mu, beta };
263 return getClass().getSimpleName() +
" : mu = " + mu +
", beta = " + beta;
Classes implementing continuous distributions should inherit from this base class.
Extends DiscreteDistribution to an empirical distribution function, based on the observations (sorte...
double getMedian()
Returns the median.
static LaplaceDist getInstanceFromMLE(double[] x, int n)
Creates a new instance of a Laplace distribution with parameters.
static double getVariance(double mu, double beta)
Computes and returns the variance of the Laplace distribution with parameters and.
static double getStandardDeviation(double mu, double beta)
Computes and returns the standard deviation of the Laplace distribution with parameters and .
static double density(double mu, double beta, double x)
Computes the Laplace density function.
double getMu()
Returns the parameter .
double getBeta()
Returns the parameter .
LaplaceDist(double mu, double beta)
Constructs a LaplaceDist object with parameters = mu and = beta.
double[] getParams()
Return a table containing the parameters of the current distribution.
double getVariance()
Returns the variance.
LaplaceDist()
Constructs a LaplaceDist object with default parameters and .
static double cdf(double mu, double beta, double x)
Computes the Laplace distribution function.
double barF(double x)
Returns the complementary distribution function.
static double getMean(double mu, double beta)
Computes and returns the mean of the Laplace distribution with parameters and .
double getMean()
Returns the mean.
static double inverseF(double mu, double beta, double u)
Computes the inverse Laplace distribution function.
String toString()
Returns a String containing information about the current distribution.
double inverseF(double u)
Returns the inverse distribution function .
double cdf(double x)
Returns the distribution function .
static double barF(double mu, double beta, double x)
Computes the Laplace complementary distribution function.
static double[] getMLE(double[] x, int n)
Estimates the parameters of the Laplace distribution using the maximum likelihood method,...
double getStandardDeviation()
Returns the standard deviation.
double density(double x)
Returns , the density evaluated at .
This class provides various constants and methods to compute numerical quantities such as factorials,...
static final double RAC2
The value of .