1
2
3
4
5
6
7
8
9
10 package nl.tudelft.simulation.jstats.distributions;
11
12 import cern.jet.stat.Gamma;
13 import nl.tudelft.simulation.jstats.streams.StreamInterface;
14
15 /***
16 * The Pearson5 distribution. For more information on this distribution see <a
17 * href="http://mathworld.wolfram.com/Pearson5Distribution.html">
18 * http://mathworld.wolfram.com/Pearson5Distribution.html </a>
19 * <p>
20 * (c) copyright 2002-2004 <a href="http://www.simulation.tudelft.nl">Delft
21 * University of Technology </a>, the Netherlands. <br>
22 * See for project information <a href="http://www.simulation.tudelft.nl">
23 * www.simulation.tudelft.nl </a> <br>
24 * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
25 * License (GPL) </a>, no warranty <br>
26 *
27 * @author <a href="http://www.tbm.tudelft.nl/webstaf/alexandv/index.htm">
28 * Alexander Verbraeck </a> <br>
29 * <a href="http://www.tbm.tudelft.nl/webstaf/peterja/index.htm"> Peter
30 * Jacobs </a>
31 * @version 1.9 2004-03-22
32 * @since 1.2
33 */
34 public class DistPearson5 extends DistContinuous
35 {
36 /*** dist is the gamma distribution */
37 private DistGamma dist;
38
39 /*** alpha is the alpha parameter of the distribution */
40 private double alpha;
41
42 /*** beta is the beta parameter of the distribtution */
43 private double beta;
44
45 /***
46 * constructs a new Pearson5 distribution
47 *
48 * @param stream the numberstream
49 * @param alpha the scale parameter
50 * @param beta the shape parameter
51 */
52 public DistPearson5(final StreamInterface stream, final double alpha,
53 final double beta)
54 {
55 super(stream);
56 if ((alpha > 0.0) && (beta > 0.0))
57 {
58 this.alpha = alpha;
59 this.beta = beta;
60 } else
61 {
62 throw new IllegalArgumentException(
63 "Error alpha <= 0.0 or beta <= 0.0");
64 }
65 this.dist = new DistGamma(stream, this.alpha, 1.0d / this.beta);
66 }
67
68 /***
69 * @see DistContinuous#draw()
70 */
71 public double draw()
72 {
73
74
75 return 1.0d / this.dist.draw();
76 }
77
78 /***
79 * @see nl.tudelft.simulation.jstats.distributions.DistContinuous
80 * #probDensity(double)
81 */
82 public double probDensity(final double observation)
83 {
84 if (observation > 0)
85 {
86 return (Math.pow(observation, -1 * (this.alpha + 1)) * Math
87 .exp(-this.beta / observation))
88 / (Math.pow(this.beta, -this.alpha) * Gamma
89 .gamma(this.alpha));
90 }
91 return 0;
92 }
93
94 /***
95 * @see java.lang.Object#toString()
96 */
97 public String toString()
98 {
99 return "Pearson5(" + this.alpha + "," + this.beta + ")";
100 }
101 }