JSci.maths.statistics.ParetoDistribution 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 ParetoDistribution class provides an object for encapsulating Pareto distributions.
* @version 0.2
* @author Mark Hale
*/
public final class ParetoDistribution extends ProbabilityDistribution {
private double shape;
private double scale;
/**
* Constructs a Pareto distribution.
* @param sh the shape.
* @param sc the scale.
*/
public ParetoDistribution(double sh,double sc) {
if(sh<0.0)
throw new OutOfRangeException("The shape parameter should be positive.");
shape=sh;
if(sc<0.0)
throw new OutOfRangeException("The scale paremeter should be positive.");
scale=sc;
}
/**
* Returns the shape parameter.
*/
public double getShapeParameter() {
return shape;
}
/**
* Returns the scale parameter.
*/
public double getScaleParameter() {
return scale;
}
/**
* Returns the mean.
*/
public double getMean() {
return shape*scale/(shape-1.0);
}
/**
* Returns the variance.
*/
public double getVariance() {
return shape*scale*scale/((shape-2.0)*(shape-1.0)*(shape-1.0));
}
/**
* Probability density function of a Pareto distribution.
* P(X) = (a/X) (s/X)a.
* @return the probability that a stochastic variable x has the value X, i.e. P(x=X).
*/
public double probability(double X) {
if(X