25package umontreal.ssj.probdist;
27import umontreal.ssj.util.Num;
28import umontreal.ssj.functions.MathFunction;
57 public Function(
double s,
int n) {
62 public double evaluate(
double k) {
79 return Math.exp((nu - 1) * Math.log(x) - x * x / 2.0 - C1);
82 public double cdf(
double x) {
86 public double barF(
double x) {
103 return ChiDist.getStandardDeviation(nu);
109 public static double density(
int nu,
double x) {
111 throw new IllegalArgumentException(
"nu <= 0");
114 return Math.exp((nu - 1) * Math.log(x) - x * x / 2.0 - (nu / 2.0 - 1.0) *
Num.
LN2 -
Num.
lnGamma(nu / 2.0));
120 public static double cdf(
int nu,
double x) {
129 public static double barF(
int nu,
double x) {
140 return Math.sqrt(2 * res);
153 public static double[]
getMLE(
double[] x,
int n) {
154 double[] parameters =
new double[1];
157 for (
int i = 0; i < n; i++)
162 for (
int i = 0; i < n; i++)
163 var += ((x[i] - mean) * (x[i] - mean));
166 double k = Math.round(var + mean * mean) - 5.0;
171 for (
int i = 0; i < n; i++) {
173 sum += Math.log(x[i]);
178 Function f =
new Function(sum, n);
179 while (f.evaluate(k) > 0.0)
195 double parameters[] =
getMLE(x, n);
196 return new ChiDist((
int) parameters[0]);
209 throw new IllegalArgumentException(
"nu <= 0");
225 throw new IllegalArgumentException(
"nu <= 0");
226 double mean =
ChiDist.getMean(nu);
227 return (nu - (mean * mean));
237 return Math.sqrt(
ChiDist.getVariance(nu));
252 throw new IllegalArgumentException(
"nu <= 0");
262 double[] retour = { nu };
270 return getClass().getSimpleName() +
" : nu = " + nu;
int getNu()
Returns the value of for this object.
double getVariance()
Returns the variance.
static double barF(int nu, double x)
Computes the complementary distribution.
ChiDist(int nu)
Constructs a ChiDist object.
static double cdf(int nu, double x)
Computes the distribution function by using the gamma distribution function.
double density(double x)
Returns , the density evaluated at .
static double density(int nu, double x)
Computes the density function.
double getStandardDeviation()
Returns the standard deviation.
static double inverseF(int nu, double u)
Returns the inverse distribution function computed using the gamma inversion.
void setNu(int nu)
Sets the value of for this object.
double inverseF(double u)
Returns the inverse distribution function .
static double getStandardDeviation(int nu)
Computes and returns the standard deviation of the chi distribution with parameter .
double getMean()
Returns the mean.
double[] getParams()
Return a table containing parameters of the current distribution.
static double[] getMLE(double[] x, int n)
Estimates the parameter of the chi distribution using the maximum likelihood method,...
double barF(double x)
Returns the complementary distribution function.
double cdf(double x)
Returns the distribution function .
static double getVariance(int nu)
Computes and returns the variance.
String toString()
Returns a String containing information about the current distribution.
static ChiDist getInstanceFromMLE(double[] x, int n)
Creates a new instance of a chi distribution with parameter.
static double getMean(int nu)
Computes and returns the mean.
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.
This class provides various constants and methods to compute numerical quantities such as factorials,...
static final double RAC2
The value of .
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.
static final double LN2
The values of .
This interface should be implemented by classes which represent univariate mathematical functions.