Class Zipf

All Implemented Interfaces:
Serializable, Copyable

public class Zipf extends DiscreteDistribution
A Zipf-like probability distribution
See Also:
  • Constructor Details

    • Zipf

      public Zipf(double s, int n)
      Construct a Zipf-like distribution
      Parameters:
      s - - the shape
      n - - 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

      public static void main(String[] args)
    • evalCDF

      public double evalCDF(double t)
      Evaluates the cumulative distribution function at t
      Specified by:
      evalCDF in class Distribution
      Parameters:
      t - - the point where the cdf will be evaluated
      Returns:
      - the cdf evaluated at t
    • evalPMF

      public Matrix evalPMF()
    • evalPMF

      public Matrix evalPMF(List<Double> t)
      Evaluates the probability mass function at t
      Overrides:
      evalPMF in class DiscreteDistribution
      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:
      getMean in class Distribution
      Returns:
      - the mean of the distribution
    • getSCV

      public double getSCV()
      Computes the squared coefficient of variation == variance/mean^2
      Specified by:
      getSCV in class Distribution
      Returns:
      - the squared coefficient of variation
    • getSkewness

      public double getSkewness()
      Description copied from class: Distribution
      Gets the skewness of this distribution. Skewness measures the asymmetry of the probability distribution.
      Specified by:
      getSkewness in class Distribution
      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:
      evalLST in class DiscreteDistribution
      Parameters:
      s - the Laplace domain variable
      Returns:
      the LST value at s
    • sample

      public double[] sample(int n, Random random)
      Generates samples from the Zipf distribution using the specified random generator. Uses the inverse transform sampling method.
      Specified by:
      sample in class Distribution
      Parameters:
      n - the number of samples to generate
      random - 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:
      sample in class Distribution
      Parameters:
      n - - the number of samples
      Returns:
      - n samples from the distribution
    • getProcess

      public MatrixCell getProcess()