25package umontreal.ssj.probdist;
27import umontreal.ssj.util.*;
28import umontreal.ssj.functions.MathFunction;
46 protected double lambda;
48 private double factor;
63 return 2.0 * Math.exp(factor + Math.log(x - a) * (2.0 * c - 1.0) - lambda * (x - a) * (x - a));
66 public double cdf(
double x) {
67 return cdf(a, lambda, c, x);
70 public double barF(
double x) {
71 return barF(a, lambda, c, x);
79 return a + ratio / Math.sqrt(lambda);
83 return (c - ratio * ratio) / lambda;
99 public static double density(
double a,
double lambda,
double c,
double x) {
101 throw new IllegalArgumentException(
"lambda <= 0");
103 throw new IllegalArgumentException(
"c <= 0");
107 return 2.0 * Math.exp(
108 Math.log(lambda) * c -
Num.
lnGamma(c) + Math.log(x - a) * (2.0 * c - 1.0) - lambda * (x - a) * (x - a));
120 public static double cdf(
double a,
double lambda,
double c,
double x) {
122 throw new IllegalArgumentException(
"lambda <= 0");
124 throw new IllegalArgumentException(
"c <= 0");
128 return GammaDist.
cdf(c, 12, lambda * (x - a) * (x - a));
140 public static double barF(
double a,
double lambda,
double c,
double x) {
142 throw new IllegalArgumentException(
"lambda <= 0");
144 throw new IllegalArgumentException(
"c <= 0");
159 public static double inverseF(
double a,
double lambda,
double c,
double u) {
161 throw new IllegalArgumentException(
"lambda <= 0");
163 throw new IllegalArgumentException(
"c <= 0");
164 if (u > 1.0 || u < 0.0)
165 throw new IllegalArgumentException(
"u not in [0,1]");
169 return Double.POSITIVE_INFINITY;
171 return a + Math.sqrt(res / lambda);
183 public static double getMean(
double a,
double lambda,
double c) {
185 throw new IllegalArgumentException(
"lambda <= 0");
187 throw new IllegalArgumentException(
"c <= 0");
200 public static double getVariance(
double a,
double lambda,
double c) {
202 throw new IllegalArgumentException(
"lambda <= 0");
204 throw new IllegalArgumentException(
"c <= 0");
206 return (c - rat * rat) / lambda;
219 return Math.sqrt(
NakagamiDist.getVariance(a, lambda, c));
256 public void setParams(
double a,
double lambda,
double c) {
258 throw new IllegalArgumentException(
"lambda <= 0");
260 throw new IllegalArgumentException(
"c <= 0");
262 this.lambda = lambda;
264 factor = (Math.log(lambda) * c -
Num.
lnGamma(c));
275 double[] retour = { a, lambda, c };
286 return getClass().getSimpleName() +
" : a = " + a +
", lambda = " + lambda +
", c = " + c;
Classes implementing continuous distributions should inherit from this base class.
Extends the class ContinuousDistribution for the gamma distribution tjoh95a (page 337) with shape pa...
double inverseF(double u)
Returns the inverse distribution function .
double cdf(double x)
Returns the distribution function .
double barF(double x)
Returns the complementary distribution function.
double inverseF(double u)
Returns the inverse distribution function .
double getStandardDeviation()
Returns the standard deviation.
double cdf(double x)
Returns the distribution function .
static double inverseF(double a, double lambda, double c, double u)
Computes the inverse of the distribution function.
void setParams(double a, double lambda, double c)
Sets the parameters , and of this object.
double getC()
Returns the shape parameter of this object.
NakagamiDist(double a, double lambda, double c)
Constructs a NakagamiDist object with parameters a,.
static double getStandardDeviation(double a, double lambda, double c)
Computes the standard deviation of the Nakagami distribution with parameters , and .
double density(double x)
Returns , the density evaluated at .
double getA()
Returns the location parameter of this object.
static double barF(double a, double lambda, double c, double x)
Computes the complementary distribution function.
double[] getParams()
Return a table containing the parameters of the current distribution.
double getLambda()
Returns the scale parameter of this object.
static double cdf(double a, double lambda, double c, double x)
Computes the distribution function.
String toString()
Returns a String containing information about the current distribution.
static double getVariance(double a, double lambda, double c)
Computes and returns the variance.
double getVariance()
Returns the variance.
double getMean()
Returns the mean.
double barF(double x)
Returns the complementary distribution function.
static double density(double a, double lambda, double c, double x)
Computes the density function of the Nakagami distribution.
static double getMean(double a, double lambda, double c)
Computes and returns the mean.
This class provides various constants and methods to compute numerical quantities such as factorials,...
static double lnGamma(double x)
Returns the natural logarithm of the gamma function evaluated at x.
static double gammaRatioHalf(double x)
Returns the value of the ratio of two gamma functions.