Class Zipf

All Implemented Interfaces:
Serializable

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)
    • 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()
      Specified by:
      getSkewness in class 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
    • sample

      public double[] sample(int n, Random random)
      Specified by:
      sample in class Distribution
    • 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