25package umontreal.ssj.probdist;
27import umontreal.ssj.util.Num;
52 protected double alpha;
53 protected double beta;
54 protected double logam;
68 return Math.exp(alpha * Math.log(beta / x) - (beta / x) - logam) / x;
71 public double cdf(
double x) {
72 return cdf(alpha, beta, x);
75 public double barF(
double x) {
76 return barF(alpha, beta, x);
99 public static double density(
double alpha,
double beta,
double x) {
101 throw new IllegalArgumentException(
"alpha <= 0");
103 throw new IllegalArgumentException(
"beta <= 0");
107 return Math.exp(alpha * Math.log(beta / x) - (beta / x) -
Num.
lnGamma(alpha)) / x;
115 public static double cdf(
double alpha,
double beta,
double x) {
117 throw new IllegalArgumentException(
"alpha <= 0");
119 throw new IllegalArgumentException(
"beta <= 0");
131 public static double barF(
double alpha,
double beta,
double x) {
133 throw new IllegalArgumentException(
"alpha <= 0");
135 throw new IllegalArgumentException(
"beta <= 0");
146 public static double inverseF(
double alpha,
double beta,
double u) {
148 throw new IllegalArgumentException(
"alpha <= 0");
150 throw new IllegalArgumentException(
"beta <= 0");
167 public static double[]
getMLE(
double[] x,
int n) {
168 double[] y =
new double[n];
170 for (
int i = 0; i < n; i++) {
190 double parameters[] =
getMLE(x, n);
199 public static double getMean(
double alpha,
double beta) {
201 throw new IllegalArgumentException(
"alpha <= 0");
203 throw new IllegalArgumentException(
"beta <= 0");
205 return (beta / (alpha - 1.0));
215 throw new IllegalArgumentException(
"alpha <= 0");
217 throw new IllegalArgumentException(
"beta <= 0");
219 return ((beta * beta) / ((alpha - 1.0) * (alpha - 1.0) * (alpha - 2.0)));
249 throw new IllegalArgumentException(
"alpha <= 0");
251 throw new IllegalArgumentException(
"beta <= 0");
263 double[] retour = { alpha, beta };
271 return getClass().getSimpleName() +
" : alpha = " + alpha +
", beta = " + beta;
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 .
static double[] getMLE(double[] x, int n)
Estimates the parameters of the gamma distribution using the maximum likelihood method,...
double barF(double x)
Returns the complementary distribution function.
double getAlpha()
Returns the parameter of this object.
double getMean()
Returns the mean.
double inverseF(double u)
Returns the inverse distribution function .
static double getVariance(double alpha, double beta)
Returns the variance of the inverse gamma distribution with shape parameter and scale parameter .
static double getStandardDeviation(double alpha, double beta)
Returns the standard deviation of the inverse gamma distribution with shape parameter and scale para...
double cdf(double x)
Returns the distribution function .
static double[] getMLE(double[] x, int n)
Estimates the parameters of the inverse gamma distribution using the maximum likelihood method,...
double density(double x)
Returns , the density evaluated at .
double barF(double x)
Returns the complementary distribution function.
double getBeta()
Returns the parameter of this object.
static double getMean(double alpha, double beta)
Returns the mean of the inverse gamma distribution with shape parameter and scale parameter .
static double cdf(double alpha, double beta, double x)
Computes the cumulative probability function of the inverse gamma distribution with shape parameter ...
static double density(double alpha, double beta, double x)
Computes the density function of the inverse gamma distribution with shape parameter and scale param...
double getStandardDeviation()
Returns the standard deviation.
double getVariance()
Returns the variance.
void setParam(double alpha, double beta)
Sets the parameters and of this object.
static double inverseF(double alpha, double beta, double u)
Computes the inverse distribution function of the inverse gamma distribution with shape parameter an...
static InverseGammaDist getInstanceFromMLE(double[] x, int n)
Creates a new instance of the inverse gamma distribution with parameters and estimated using the ma...
static double barF(double alpha, double beta, double x)
Computes the complementary distribution function of the inverse gamma distribution with shape paramet...
InverseGammaDist(double alpha, double beta)
Constructs an InverseGammaDist object with parameters.
String toString()
Returns a String containing information about the current distribution.
double[] getParams()
Returns a table containing the parameters of the current distribution.
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.