01: package JSci.maths.statistics;
02:
03: /**
04: * The LognormalDistribution class provides an object for encapsulating lognormal distributions.
05: * @version 0.1
06: * @author Mark Hale
07: */
08: public final class LognormalDistribution extends
09: ProbabilityDistribution {
10: private NormalDistribution normal;
11:
12: /**
13: * Constructs a standard lognormal distribution.
14: */
15: public LognormalDistribution() {
16: this (0.0, 1.0);
17: }
18:
19: /**
20: * Constructs a lognormal distribution.
21: * @param mu the mu parameter.
22: * @param sigma the sigma parameter.
23: */
24: public LognormalDistribution(double mu, double sigma) {
25: normal = new NormalDistribution(mu, sigma * sigma);
26: }
27:
28: /**
29: * Returns the mu parameter.
30: */
31: public double getMuParameter() {
32: return normal.getMean();
33: }
34:
35: /**
36: * Returns the sigma parameter.
37: */
38: public double getSigmaParameter() {
39: return Math.sqrt(normal.getVariance());
40: }
41:
42: /**
43: * Probability density function of a lognormal distribution.
44: * @return the probability that a stochastic variable x has the value X, i.e. P(x=X).
45: */
46: public double probability(double X) {
47: checkRange(X, 0.0, Double.MAX_VALUE);
48: return normal.probability(Math.log(X)) / X;
49: }
50:
51: /**
52: * Cumulative lognormal distribution function.
53: * @return the probability that a stochastic variable x is less then X, i.e. P(x<X).
54: */
55: public double cumulative(double X) {
56: checkRange(X, 0.0, Double.MAX_VALUE);
57: return normal.cumulative(Math.log(X));
58: }
59:
60: /**
61: * Inverse of the cumulative lognormal distribution function.
62: * @return the value X for which P(x<X).
63: */
64: public double inverse(double probability) {
65: return Math.exp(normal.inverse(probability));
66: }
67: }
|