JSci.maths.statistics.LognormalDistribution Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jsci Show documentation
Show all versions of jsci Show documentation
JSci is a set of open source Java packages. The aim is to encapsulate scientific methods/principles in the most natural way possible. As such they should greatly aid the development of scientific based software.
It offers: abstract math interfaces, linear algebra (support for various matrix and vector types), statistics (including probability distributions), wavelets, newtonian mechanics, chart/graph components (AWT and Swing), MathML DOM implementation, ...
Note: some packages, like javax.comm, for the astro and instruments package aren't listed as dependencies (not available).
The newest version!
package JSci.maths.statistics;
/**
* The LognormalDistribution class provides an object for encapsulating lognormal distributions.
* @version 0.1
* @author Mark Hale
*/
public final class LognormalDistribution extends ProbabilityDistribution {
private NormalDistribution normal;
/**
* Constructs a standard lognormal distribution.
*/
public LognormalDistribution() {
this(0.0,1.0);
}
/**
* Constructs a lognormal distribution.
* @param mu the mu parameter.
* @param sigma the sigma parameter.
*/
public LognormalDistribution(double mu,double sigma) {
normal=new NormalDistribution(mu,sigma*sigma);
}
/**
* Returns the mu parameter.
*/
public double getMuParameter() {
return normal.getMean();
}
/**
* Returns the sigma parameter.
*/
public double getSigmaParameter() {
return Math.sqrt(normal.getVariance());
}
/**
* Probability density function of a lognormal distribution.
* @return the probability that a stochastic variable x has the value X, i.e. P(x=X).
*/
public double probability(double X) {
checkRange(X,0.0,Double.MAX_VALUE);
return normal.probability(Math.log(X))/X;
}
/**
* Cumulative lognormal distribution function.
* @return the probability that a stochastic variable x is less than or equal to X, i.e. P(x<=X).
*/
public double cumulative(double X) {
checkRange(X,0.0,Double.MAX_VALUE);
return normal.cumulative(Math.log(X));
}
/**
* Inverse of the cumulative lognormal distribution function.
* @return the value X for which P(x<=X).
*/
public double inverse(double probability) {
return Math.exp(normal.inverse(probability));
}
}