25package umontreal.ssj.probdist;
27import umontreal.ssj.probdist.NormalDist;
28import umontreal.ssj.util.Num;
52 protected double alpha;
53 protected double beta;
54 protected double gamma;
55 protected double delta;
69 return density(alpha, beta, mu, delta, x);
72 public double cdf(
double x) {
73 return cdf(alpha, beta, mu, delta, x);
76 public double barF(
double x) {
77 return barF(alpha, beta, mu, delta, x);
81 return getMean(alpha, beta, mu, delta);
99 public static double density(
double alpha,
double beta,
double mu,
double delta,
double x) {
101 throw new IllegalArgumentException(
"delta <= 0");
103 throw new IllegalArgumentException(
"alpha <= 0");
104 if (Math.abs(beta) >= alpha)
105 throw new IllegalArgumentException(
"|beta| >= alpha");
107 double gamma = Math.sqrt(alpha * alpha - beta * beta);
108 double z = (x - mu) / delta;
110 if (Math.abs(z) <= 1.0e10)
111 w = Math.sqrt(1.0 + z * z);
114 double y = alpha * delta * w;
115 double v = delta * (gamma + beta * z);
117 return alpha * R / (Math.PI * w);
127 public static double cdf(
double alpha,
double beta,
double mu,
double delta,
double x) {
129 throw new IllegalArgumentException(
"delta <= 0");
131 throw new IllegalArgumentException(
"alpha <= 0");
132 if (Math.abs(beta) >= alpha)
133 throw new IllegalArgumentException(
"|beta| >= alpha");
135 double gamma = Math.sqrt(alpha * alpha - beta * beta);
136 double z = (x - mu) / delta;
137 if (z > 0.0 && (gamma + (beta - alpha) * z >= XBIG))
139 if (z < 0.0 && (gamma + (beta + alpha) * z <= -XBIGM))
143 throw new UnsupportedOperationException(
"NormalInverseGaussianDist: cdf NOT IMPLEMENTED");
152 public static double barF(
double alpha,
double beta,
double mu,
double delta,
double x) {
153 return 1.0 -
cdf(alpha, beta, mu, delta, x);
162 public static double inverseF(
double alpha,
double beta,
double mu,
double delta,
double u) {
163 throw new UnsupportedOperationException(
" Inversion NOT IMPLEMENTED");
174 public static double[]
getMLE(
double[] x,
int n) {
176 throw new IllegalArgumentException(
"n <= 0");
181 throw new UnsupportedOperationException(
"getMLE is not implemented");
193 double parameters[] =
getMLE(x, n);
205 public static double getMean(
double alpha,
double beta,
double mu,
double delta) {
207 throw new IllegalArgumentException(
"delta <= 0");
209 throw new IllegalArgumentException(
"alpha <= 0");
210 if (Math.abs(beta) >= alpha)
211 throw new IllegalArgumentException(
"|beta| >= alpha");
213 double gamma = Math.sqrt(alpha * alpha - beta * beta);
214 return mu + delta * beta / gamma;
225 public static double getVariance(
double alpha,
double beta,
double mu,
double delta) {
227 throw new IllegalArgumentException(
"delta <= 0");
229 throw new IllegalArgumentException(
"alpha <= 0");
230 if (Math.abs(beta) >= alpha)
231 throw new IllegalArgumentException(
"|beta| >= alpha");
233 double gamma = Math.sqrt(alpha * alpha - beta * beta);
234 return delta * alpha * alpha / (gamma * gamma * gamma);
245 return Math.sqrt(
getVariance(alpha, beta, mu, delta));
281 public void setParams(
double alpha,
double beta,
double mu,
double delta) {
283 throw new IllegalArgumentException(
"delta <= 0");
285 throw new IllegalArgumentException(
"alpha <= 0");
286 if (Math.abs(beta) >= alpha)
287 throw new IllegalArgumentException(
"|beta| >= alpha");
289 gamma = Math.sqrt(alpha * alpha - beta * beta);
303 double[] retour = { alpha, beta, mu, delta };
311 return getClass().getSimpleName() +
": alpha = " + alpha +
", beta = " + beta +
", mu = " + mu +
", delta = "
Classes implementing continuous distributions should inherit from this base class.
double[] getParams()
Returns a table containing the parameters of the current distribution.
double getVariance()
Returns the variance.
static double getStandardDeviation(double alpha, double beta, double mu, double delta)
Computes and returns the standard deviation of the normal inverse gaussian distribution with paramete...
double cdf(double x)
Returns the distribution function .
static NormalInverseGaussianDist getInstanceFromMLE(double[] x, int n)
NOT IMPLEMENTED.
NormalInverseGaussianDist(double alpha, double beta, double mu, double delta)
Constructor for a normal inverse gaussian distribution with parameters = alpha, = beta,...
static double density(double alpha, double beta, double mu, double delta, double x)
Computes the density function ( fNormalInverseGaussian ) for the normal inverse gaussian distribution...
double getStandardDeviation()
Returns the standard deviation.
static double[] getMLE(double[] x, int n)
NOT IMPLEMENTED.
double getAlpha()
Returns the parameter of this object.
static double getVariance(double alpha, double beta, double mu, double delta)
Computes and returns the variance of the normal inverse gaussian distribution with parameters ,...
double barF(double x)
Returns the complementary distribution function.
double getMu()
Returns the parameter of this object.
double density(double x)
Returns , the density evaluated at .
double getDelta()
Returns the parameter of this object.
static double inverseF(double alpha, double beta, double mu, double delta, double u)
NOT IMPLEMENTED.
String toString()
Returns a String containing information about the current distribution.
double getMean()
Returns the mean.
double getBeta()
Returns the parameter of this object.
static double getMean(double alpha, double beta, double mu, double delta)
Returns the mean of the normal inverse gaussian distribution with parameters.
static double barF(double alpha, double beta, double mu, double delta, double x)
NOT IMPLEMENTED.
static double cdf(double alpha, double beta, double mu, double delta, double x)
NOT IMPLEMENTED.
void setParams(double alpha, double beta, double mu, double delta)
Sets the parameters , , and.
This class provides various constants and methods to compute numerical quantities such as factorials,...
static double expBesselK1(double x, double y)
Returns the value of , where is the modified Bessel function of the second kind of order 1.