Package jline.lang.processes
Class Zipf
java.lang.Object
jline.lang.processes.Distribution
jline.lang.processes.DiscreteDistribution
jline.lang.processes.Zipf
- All Implemented Interfaces:
Serializable
A Zipf-like probability distribution
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondouble
evalCDF
(double t) Evaluates the cumulative distribution function at tevalPMF()
Evaluates the probability mass function at tstatic double
genHarmonic
(double s, int n) Generate harmonic numbers to normalize a Zipf-like distribution on n items with shape sdouble
getMean()
Computes the distribution meandouble
getSCV()
Computes the squared coefficient of variation == variance/mean^2double
static void
double[]
sample
(int n) Gets n samples from the distributiondouble[]
Methods inherited from class jline.lang.processes.DiscreteDistribution
evalPMF, evalPMF
Methods inherited from class jline.lang.processes.Distribution
evalProbInterval, getName, getNumParams, getParam, getRate, getSupport, getVar, isContinuous, isDisabled, isDiscrete, isImmediate, setNumParams, setParam
-
Constructor Details
-
Zipf
public Zipf(double s, int n) Construct a Zipf-like distribution- Parameters:
s
- - the shapen
- - number of items
-
-
Method Details
-
genHarmonic
public static double genHarmonic(double s, int n) Generate harmonic numbers to normalize a Zipf-like distribution on n items with shape s -
main
-
getMean
public double getMean()Computes the distribution mean- Specified by:
getMean
in classDistribution
- Returns:
- - the mean of the distribution
-
getSCV
public double getSCV()Computes the squared coefficient of variation == variance/mean^2- Specified by:
getSCV
in classDistribution
- Returns:
- - the squared coefficient of variation
-
getSkewness
public double getSkewness()- Specified by:
getSkewness
in classDistribution
-
sample
public double[] sample(int n) Gets n samples from the distribution- Overrides:
sample
in classDistribution
- Parameters:
n
- - the number of samples- Returns:
- - n samples from the distribution
-
sample
- Specified by:
sample
in classDistribution
-
evalCDF
public double evalCDF(double t) Evaluates the cumulative distribution function at t- Specified by:
evalCDF
in classDistribution
- Parameters:
t
- - the point where the cdf will be evaluated- Returns:
- - the cdf evaluated at t
-
evalPMF
-
evalPMF
Evaluates the probability mass function at t- Overrides:
evalPMF
in classDiscreteDistribution
- Parameters:
t
- - the point where the pmf will be evaluated- Returns:
- - the pfm evaluated at t
-