SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
Pearson5Dist.java
1/*
2 * Class: Pearson5Dist
3 * Description: Pearson type V distribution
4 * Environment: Java
5 * Software: SSJ
6 * Copyright (C) 2001 Pierre L'Ecuyer and Universite de Montreal
7 * Organization: DIRO, Universite de Montreal
8 * @author
9 * @since
10 *
11 *
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 *
24 */
25package umontreal.ssj.probdist;
26
27import umontreal.ssj.util.Num;
28
52@Deprecated
54 protected double alpha;
55 protected double beta;
56 protected double logam; // Ln (Gamma(alpha))
57
64 public Pearson5Dist(double alpha, double beta) {
65 setParam(alpha, beta);
66 }
67
68 public double density(double x) {
69 if (x <= 0.0)
70 return 0.0;
71 return Math.exp(alpha * Math.log(beta / x) - (beta / x) - logam) / x;
72 }
73
74 public double cdf(double x) {
75 return cdf(alpha, beta, x);
76 }
77
78 public double barF(double x) {
79 return barF(alpha, beta, x);
80 }
81
82 public double inverseF(double u) {
83 return inverseF(alpha, beta, u);
84 }
85
86 public double getMean() {
87 return getMean(alpha, beta);
88 }
89
90 public double getVariance() {
91 return getVariance(alpha, beta);
92 }
93
94 public double getStandardDeviation() {
95 return getStandardDeviation(alpha, beta);
96 }
97
102 public static double density(double alpha, double beta, double x) {
103 if (alpha <= 0.0)
104 throw new IllegalArgumentException("alpha <= 0");
105 if (beta <= 0.0)
106 throw new IllegalArgumentException("beta <= 0");
107 if (x <= 0.0)
108 return 0.0;
109
110 return Math.exp(alpha * Math.log(beta / x) - (beta / x) - Num.lnGamma(alpha)) / x;
111 }
112
117 public static double cdf(double alpha, double beta, double x) {
118 if (alpha <= 0.0)
119 throw new IllegalArgumentException("alpha <= 0");
120 if (beta <= 0.0)
121 throw new IllegalArgumentException("beta <= 0");
122 if (x <= 0.0)
123 return 0.0;
124
125 return GammaDist.barF(alpha, beta, 15, 1.0 / x);
126 }
127
132 public static double barF(double alpha, double beta, double x) {
133 if (alpha <= 0.0)
134 throw new IllegalArgumentException("alpha <= 0");
135 if (beta <= 0.0)
136 throw new IllegalArgumentException("beta <= 0");
137 if (x <= 0.0)
138 return 1.0;
139
140 return GammaDist.cdf(alpha, beta, 15, 1.0 / x);
141 }
142
147 public static double inverseF(double alpha, double beta, double u) {
148 if (alpha <= 0.0)
149 throw new IllegalArgumentException("alpha <= 0");
150 if (beta <= 0.0)
151 throw new IllegalArgumentException("beta <= 0");
152
153 return 1.0 / GammaDist.inverseF(alpha, beta, 15, 1 - u);
154 }
155
168 public static double[] getMLE(double[] x, int n) {
169 double[] y = new double[n];
170
171 for (int i = 0; i < n; i++) {
172 if (x[i] > 0)
173 y[i] = 1.0 / x[i];
174 else
175 y[i] = 1.0E100;
176 }
177
178 return GammaDist.getMLE(y, n);
179 }
180
190 public static Pearson5Dist getInstanceFromMLE(double[] x, int n) {
191 double parameters[] = getMLE(x, n);
192 return new Pearson5Dist(parameters[0], parameters[1]);
193 }
194
200 public static double getMean(double alpha, double beta) {
201 if (alpha <= 0.0)
202 throw new IllegalArgumentException("alpha <= 0");
203 if (beta <= 0.0)
204 throw new IllegalArgumentException("beta <= 0");
205
206 return (beta / (alpha - 1.0));
207 }
208
214 public static double getVariance(double alpha, double beta) {
215 if (alpha <= 0.0)
216 throw new IllegalArgumentException("alpha <= 0");
217 if (beta <= 0.0)
218 throw new IllegalArgumentException("beta <= 0");
219
220 return ((beta * beta) / ((alpha - 1.0) * (alpha - 1.0) * (alpha - 2.0)));
221 }
222
227 public static double getStandardDeviation(double alpha, double beta) {
228 return Math.sqrt(getVariance(alpha, beta));
229 }
230
234 public double getAlpha() {
235 return alpha;
236 }
237
241 public double getBeta() {
242 return beta;
243 }
244
248 public void setParam(double alpha, double beta) {
249 if (alpha <= 0.0)
250 throw new IllegalArgumentException("alpha <= 0");
251 if (beta <= 0.0)
252 throw new IllegalArgumentException("beta <= 0");
253 supportA = 0.0;
254 this.alpha = alpha;
255 this.beta = beta;
256 logam = Num.lnGamma(alpha);
257 }
258
263 public double[] getParams() {
264 double[] retour = { alpha, beta };
265 return retour;
266 }
267
271 public String toString() {
272 return getClass().getSimpleName() + " : alpha = " + alpha + ", beta = " + beta;
273 }
274
275}
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.
static double inverseF(double alpha, double beta, double u)
Computes the inverse distribution function of a Pearson V distribution with shape parameter and scal...
double inverseF(double u)
Returns the inverse distribution function .
double density(double x)
Returns , the density evaluated at .
double[] getParams()
Return a table containing the parameters of the current distribution.
void setParam(double alpha, double beta)
Sets the parameters and of this object.
double getVariance()
Returns the variance.
String toString()
Returns a String containing information about the current distribution.
double getAlpha()
Returns the parameter of this object.
static double[] getMLE(double[] x, int n)
Estimates the parameters of the Pearson V distribution using the maximum likelihood method,...
static double cdf(double alpha, double beta, double x)
Computes the density function of a Pearson V distribution with shape parameter and scale parameter .
double getStandardDeviation()
Returns the standard deviation.
static double getVariance(double alpha, double beta)
Computes and returns the variance of a Pearson V distribution with shape parameter and scale param...
static double barF(double alpha, double beta, double x)
Computes the complementary distribution function of a Pearson V distribution with shape parameter an...
Pearson5Dist(double alpha, double beta)
THIS CLASS HAS BEEN RENAMED InverseGammaDist .
double getBeta()
Returns the parameter of this object.
double getMean()
Returns the mean.
static double density(double alpha, double beta, double x)
Computes the density function of a Pearson V distribution with shape parameter and scale parameter .
static double getStandardDeviation(double alpha, double beta)
Computes and returns the standard deviation of a Pearson V distribution with shape parameter and sca...
double barF(double x)
Returns the complementary distribution function.
static double getMean(double alpha, double beta)
Computes and returns the mean of a Pearson V distribution with shape parameter and scale parameter ...
double cdf(double x)
Returns the distribution function .
static Pearson5Dist getInstanceFromMLE(double[] x, int n)
Creates a new instance of a Pearson V distribution with parameters.
This class provides various constants and methods to compute numerical quantities such as factorials,...
Definition Num.java:35
static double lnGamma(double x)
Returns the natural logarithm of the gamma function evaluated at x.
Definition Num.java:417