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,Copyable
A Zipf-like probability distribution
- See Also:
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleevalCDF(double t) Evaluates the cumulative distribution function at tdoubleevalLST(double s) Evaluates the Laplace-Stieltjes Transform at s.evalPMF()Evaluates the probability mass function at tstatic doublegenHarmonic(double s, int n) Generate harmonic numbers to normalize a Zipf-like distribution on n items with shape sdoublegetMean()Computes the distribution meandoublegetSCV()Computes the squared coefficient of variation == variance/mean^2doubleGets the skewness of this distribution.static voiddouble[]sample(int n) Gets n samples from the distributiondouble[]Generates samples from the Zipf distribution using the specified random generator.Methods inherited from class jline.lang.processes.DiscreteDistribution
evalPMF, evalPMFMethods inherited from class jline.lang.processes.Distribution
evalProbInterval, getName, getNumParams, getParam, getRate, getSupport, getVar, isContinuous, isDisabled, isDiscrete, isImmediate, isMarkovian, mean, name, numParams, param, rate, scv, setNumParams, setParam, skewness, support, var
-
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
-
evalCDF
public double evalCDF(double t) Evaluates the cumulative distribution function at t- Specified by:
evalCDFin 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:
evalPMFin classDiscreteDistribution- Parameters:
t- - the point where the pmf will be evaluated- Returns:
- - the pfm evaluated at t
-
getMean
public double getMean()Computes the distribution mean- Specified by:
getMeanin classDistribution- Returns:
- - the mean of the distribution
-
getSCV
public double getSCV()Computes the squared coefficient of variation == variance/mean^2- Specified by:
getSCVin classDistribution- Returns:
- - the squared coefficient of variation
-
getSkewness
public double getSkewness()Description copied from class:DistributionGets the skewness of this distribution. Skewness measures the asymmetry of the probability distribution.- Specified by:
getSkewnessin classDistribution- Returns:
- the skewness value
-
evalLST
public double evalLST(double s) Evaluates the Laplace-Stieltjes Transform at s. For Zipf distribution, LST(s) = Σ(k=1 to n) P(X=k) * e^(-s*k)- Overrides:
evalLSTin classDiscreteDistribution- Parameters:
s- the Laplace domain variable- Returns:
- the LST value at s
-
sample
Generates samples from the Zipf distribution using the specified random generator. Uses the inverse transform sampling method.- Specified by:
samplein classDistribution- Parameters:
n- the number of samples to generaterandom- the random number generator to use- Returns:
- array of samples from the Zipf distribution
-
sample
public double[] sample(int n) Gets n samples from the distribution- Overrides:
samplein classDistribution- Parameters:
n- - the number of samples- Returns:
- - n samples from the distribution
-
getProcess
-