25package umontreal.ssj.probdist;
27import umontreal.ssj.probdist.NormalDist;
57 protected double beta;
58 protected double gamma;
60 private static class Optim
implements Uncmin_methods {
65 public Optim(
double[] x,
int n,
double min) {
68 this.xi =
new double[n];
69 System.arraycopy(x, 0, this.xi, 0, n);
72 public double f_to_minimize(
double[] p) {
75 if ((p[1] <= 0.0) || (p[2] <= 0.0))
78 for (
int i = 0; i < n; i++)
79 sum -= Math.log(
density(mu, p[1], p[2], xi[i]));
84 public void gradient(
double[] x,
double[] g) {
87 public void hessian(
double[] x,
double[][] h) {
104 public double cdf(
double x) {
134 public static double density(
double mu,
double beta,
double gamma,
double x) {
136 throw new IllegalArgumentException(
"beta <= 0");
138 throw new IllegalArgumentException(
"gamma <= 0");
142 y = (Math.sqrt((x - mu) / beta) - Math.sqrt(beta / (x - mu))) / gamma;
144 return (((Math.sqrt((x - mu) / beta) + Math.sqrt(beta / (x - mu))) / (2 * gamma * (x - mu)))
153 public static double cdf(
double mu,
double beta,
double gamma,
double x) {
155 throw new IllegalArgumentException(
"beta <= 0");
157 throw new IllegalArgumentException(
"gamma <= 0");
161 return NormalDist.
cdf01((Math.sqrt((x - mu) / beta) - Math.sqrt(beta / (x - mu))) / gamma);
168 public static double barF(
double mu,
double beta,
double gamma,
double x) {
170 throw new IllegalArgumentException(
"beta <= 0");
172 throw new IllegalArgumentException(
"gamma <= 0");
176 return NormalDist.
barF01((Math.sqrt((x - mu) / beta) - Math.sqrt(beta / (x - mu))) / gamma);
183 public static double inverseF(
double mu,
double beta,
double gamma,
double u) {
185 throw new IllegalArgumentException(
"beta <= 0");
187 throw new IllegalArgumentException(
"gamma <= 0");
188 if (u > 1.0 || u < 0.0)
189 throw new IllegalArgumentException(
"u not in [0,1]");
193 return Double.POSITIVE_INFINITY;
196 double sqrtZ = 0.5 * (w + Math.sqrt(w * w + 4.0));
198 return (mu + sqrtZ * sqrtZ * beta);
217 public static double[]
getMLE(
double[] x,
int n,
double mu) {
221 throw new IllegalArgumentException(
"n <= 0");
223 double[] parameters =
new double[3];
224 double[] xpls =
new double[3];
225 double[] param =
new double[3];
226 double[] fpls =
new double[3];
227 double[] gpls =
new double[3];
228 int[] itrcmd =
new int[2];
229 double[][] h =
new double[3][3];
230 double[] udiag =
new double[3];
232 Optim system =
new Optim(x, n, mu);
235 for (
int i = 0; i < n; i++)
240 for (
int i = 0; i < n; i++)
241 var += (x[i] - mean) * (x[i] - mean);
244 double loc2 = (mean - mu) * (mean - mu);
245 double a = 0.25 * (var - 5 * loc2);
246 double b = (var - loc2);
249 double delta = b * b - 4.0 * a * c;
251 double gamma2 = (-b - Math.sqrt(delta)) / (2.0 * a);
252 param[2] = Math.sqrt(gamma2);
253 param[1] = (mean - mu) / (1.0 + gamma2 / 2.0);
255 Uncmin_f77.optif0_f77(2, param, system, xpls, fpls, gpls, itrcmd, h, udiag);
257 for (
int i = 1; i < 3; i++)
258 parameters[i] = xpls[i];
270 public static double getMean(
double mu,
double beta,
double gamma) {
272 throw new IllegalArgumentException(
"beta <= 0");
274 throw new IllegalArgumentException(
"gamma <= 0");
276 return (mu + beta * (1 + 0.5 * gamma * gamma));
286 public static double getVariance(
double mu,
double beta,
double gamma) {
288 throw new IllegalArgumentException(
"beta <= 0");
290 throw new IllegalArgumentException(
"gamma <= 0");
292 return (beta * beta * gamma * gamma * (1.0 + 5.0 / 4.0 * gamma * gamma));
329 public void setParams(
double mu,
double beta,
double gamma) {
331 throw new IllegalArgumentException(
"beta <= 0");
333 throw new IllegalArgumentException(
"gamma <= 0");
346 double[] retour = { mu, beta, gamma };
354 return getClass().getSimpleName() +
" : mu = " + mu +
", beta = " + beta +
", gamma = " + gamma;
Classes implementing continuous distributions should inherit from this base class.
static double getStandardDeviation(double mu, double beta, double gamma)
Computes and returns the standard deviation of the fatigue life distribution with parameters ,...
static double getVariance(double mu, double beta, double gamma)
Computes and returns the variance of the fatigue life distribution with parameters ,...
void setParams(double mu, double beta, double gamma)
Sets the parameters , and of this object.
static double cdf(double mu, double beta, double gamma, double x)
Computes the fatigue life distribution function with parameters.
String toString()
Returns a String containing information about the current distribution.
double getBeta()
Returns the parameter of this object.
static double barF(double mu, double beta, double gamma, double x)
Computes the complementary distribution function of the fatigue life distribution with parameters ,...
double getVariance()
Returns the variance.
double density(double x)
Returns , the density evaluated at .
double getGamma()
Returns the parameter of this object.
static double inverseF(double mu, double beta, double gamma, double u)
Computes the inverse of the fatigue life distribution with parameters , and .
double getStandardDeviation()
Returns the standard deviation.
double inverseF(double u)
Returns the inverse distribution function .
double cdf(double x)
Returns the distribution function .
static double getMean(double mu, double beta, double gamma)
Computes and returns the mean of the fatigue life distribution with parameters.
static double density(double mu, double beta, double gamma, double x)
Computes the density ( fFatigueLife ) for the fatigue life distribution with parameters.
double getMean()
Returns the mean.
double barF(double x)
Returns the complementary distribution function.
FatigueLifeDist(double mu, double beta, double gamma)
Constructs a fatigue life distribution with parameters ,.
double getMu()
Returns the parameter of this object.
static double[] getMLE(double[] x, int n, double mu)
Estimates the parameters ( , , ) of the fatigue life distribution using the maximum likelihood method...
double[] getParams()
Return a table containing the parameters of the current distribution.
Extends the class ContinuousDistribution for the normal distribution (e.g., tjoh95a (page 80)).
double density(double x)
Returns , the density evaluated at .
static double inverseF01(double u)
Same as inverseF(0, 1, u).
static double cdf01(double x)
Same as cdf(0, 1, x).
static double barF01(double x)
Same as barF(0, 1, x).