25package umontreal.ssj.probdist;
27import umontreal.ssj.util.*;
28import umontreal.ssj.functions.MathFunction;
45 protected double sigma;
57 final double z = (x - mu) / sigma;
60 return C1 * Math.exp(-z * z / 2.0);
63 public double cdf(
double x) {
64 return cdf(mu, sigma, x);
67 public double barF(
double x) {
68 return barF(mu, sigma, x);
95 public static double density(
double mu,
double sigma,
double x) {
97 throw new IllegalArgumentException(
"sigma <= 0");
98 final double Z = (x - mu) / sigma;
101 return Math.sqrt(2.0 / Math.PI) / sigma * Math.exp(-Z * Z / 2.0);
112 public static double cdf(
double mu,
double sigma,
double x) {
114 throw new IllegalArgumentException(
"sigma <= 0");
115 final double Z = (x - mu) / sigma;
129 public static double barF(
double mu,
double sigma,
double x) {
131 throw new IllegalArgumentException(
"sigma <= 0");
132 final double Z = (x - mu) / sigma;
146 public static double inverseF(
double mu,
double sigma,
double u) {
148 throw new IllegalArgumentException(
"sigma <= 0");
149 if (u > 1.0 || u < 0.0)
150 throw new IllegalArgumentException(
"u not in [0,1]");
154 return Double.POSITIVE_INFINITY;
157 return mu + sigma * Z;
175 public static double[]
getMLE(
double[] x,
int n) {
177 throw new IllegalArgumentException(
"n <= 0");
179 double mu = Double.MAX_VALUE;
180 for (
int i = 0; i < n; ++i)
185 for (
int i = 0; i < n; ++i)
186 sigma += (x[i] - mu) * (x[i] - mu);
188 double[] parametres =
new double[2];
190 parametres[1] = Math.sqrt(sigma / n);
209 public static double[]
getMLE(
double[] x,
int n,
double mu) {
211 throw new IllegalArgumentException(
"n <= 0");
214 for (
int i = 0; i < n; ++i)
215 sigma += (x[i] - mu) * (x[i] - mu);
217 double[] parametres =
new double[1];
218 parametres[0] = Math.sqrt(sigma / n);
229 public static double getMean(
double mu,
double sigma) {
231 throw new IllegalArgumentException(
"sigma <= 0");
232 return mu + sigma * Math.sqrt(2.0 / Math.PI);
245 throw new IllegalArgumentException(
"sigma <= 0");
246 return (1.0 - 2.0 / Math.PI) * sigma * sigma;
287 throw new IllegalArgumentException(
"sigma <= 0");
290 C1 = Math.sqrt(2.0 / Math.PI) / sigma;
300 double[] retour = { mu, sigma };
311 return getClass().getSimpleName() +
" : mu = " + mu +
", sigma = " + sigma;
Classes implementing continuous distributions should inherit from this base class.
static double inverseF(double mu, double sigma, double u)
Computes the inverse of the distribution function.
static double getStandardDeviation(double mu, double sigma)
Computes the standard deviation of the half-normal distribution with parameters and .
double inverseF(double u)
Returns the inverse distribution function .
static double density(double mu, double sigma, double x)
Computes the density function of the half-normal distribution.
static double getMean(double mu, double sigma)
Computes and returns the mean .
double getStandardDeviation()
Returns the standard deviation.
static double barF(double mu, double sigma, double x)
Computes the complementary distribution function.
HalfNormalDist(double mu, double sigma)
Constructs a HalfNormalDist object with parameters mu and sigma.
double getVariance()
Returns the variance.
double getMu()
Returns the parameter of this object.
double barF(double x)
Returns the complementary distribution function.
double cdf(double x)
Returns the distribution function .
static double[] getMLE(double[] x, int n, double mu)
Estimates the parameter of the half-normal distribution using the maximum likelihood method from the...
static double getVariance(double mu, double sigma)
Computes and returns the variance .
void setParams(double mu, double sigma)
Sets the parameters and .
double[] getParams()
Return a table containing the parameters of the current distribution.
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 cdf(double mu, double sigma, double x)
Computes the distribution function.
static double[] getMLE(double[] x, int n)
Estimates the parameters and of the half-normal distribution using the maximum likelihood method fr...
double getSigma()
Returns the parameter of this object.
This class provides various constants and methods to compute numerical quantities such as factorials,...
static final double RAC2
The value of .
static double erfInv(double u)
Returns the value of erf , the inverse of the error function.
static double erf(double x)
Returns the value of erf( ), the error function.
static double erfc(double x)
Returns the value of erfc( ), the complementary error function.