Module m3DCS

Class Distributions

java.lang.Object
de.grogra.blocks.arrangeBlock.Distributions

public class Distributions extends Object
offers several discrete and continuous distributions all seeded by a common well-spaced pseudo random number generator (PRNG).
  • Constructor Summary

    Constructors
    Constructor
    Description
    The seed is automatically provided by a well-spaced SeedGenerator
    Distributions(long seed)
    The seed is manually set
    This constructor allows for manually specially the continous generator shared to compute the distribution function.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    bernoulli(double prob)
    computes a Bernoulli's distribution
    double
    beta(double shape_a, double shape_b)
    computes a beta distribution using Cheng's method (1978) when shape_a>1 or shape_b>1 and Berman's method (1970) otherwise
    double
    betaprime(double shape_a, double shape_b)
    computes a beta prime distribution
    long
    binomial(double prob, int trials)
    computes a binomial distribution
    double
    cauchy(double median, double scale)
    computes a Cauchy's distribution
    double
    chisquare(long deg_freedom)
    computes a chisquare distribution
    double
    erlang(double scale, double shape)
    computes an Erlang's distribution
    double
    f(long num_deg_freedom, long den_deg_freedom)
    computes a F distribution
    double
    gamma(double scale, double shape)
    computes a gamma distribution
    long
    geometric(double prob)
    computes a geometric distribution
    double
    invgamma(double scale, double shape)
    computes an invgamma distribution
    double
    logistic(double location, double scale)
    computes a logistic distribution
    double
    lognormal(double mean, double variance)
    computes a lognormal distribution
    double
    lognormal2(double mean, double std_dev)
    computes a lognormal distribution
    double
    negexp(double mean)
    computes a negexp distribution
    double
    normal(double mean, double variance)
    computes a normal distribution; sample are provided by the same PRGN
    double
    normal2(double mean, double std_dev)
    computes a normal distribution; sample are provided by the same PRGN
    double
    pareto(double scale, double shape)
    computes a pareto distribution; sample is provided by the PRGN
    long
    pascal(double prob, int successes)
    computes a Pascal's distribution
    long
    poisson(double mean)
    computes a poisson distribution
    double
    tstudent(long deg_freedom)
    computes a tstudent distribution; sample is provided by the PRGN
    double
    uniform(double min, double max)
    computes a uniform distribution; sample is provided by the PRGN
    double
    weibull(double scale, double shape)
    computes a weibull distribution; sample is provided by the PRGN

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Distributions

      public Distributions()
      The seed is automatically provided by a well-spaced SeedGenerator
    • Distributions

      public Distributions(long seed)
      The seed is manually set
    • Distributions

      public Distributions(ContinuousGenerator gen)
      This constructor allows for manually specially the continous generator shared to compute the distribution function.
  • Method Details

    • bernoulli

      public long bernoulli(double prob)
      computes a Bernoulli's distribution
      Returns:
      1 iif sample ≤ prob, 0 otherwise; sample is provided by the PRGN
    • binomial

      public long binomial(double prob, int trials)
      computes a binomial distribution
      Returns:
      ∑(i=0; i<trials-1; bernoulli(prob))
    • geometric

      public long geometric(double prob)
      computes a geometric distribution
      Returns:
      ⌈ log(sample)/log(1-prob) ⌉; sample is provided by the PRGN
    • pascal

      public long pascal(double prob, int successes)
      computes a Pascal's distribution
      Returns:
      ∑(i=0; i<successes; geometric(prob))
    • poisson

      public long poisson(double mean)
      computes a poisson distribution
      Returns:
      the smallest integer x so as ∏(i=0; i<x; sample) ≤ exp(-mean)
    • beta

      public double beta(double shape_a, double shape_b)
      computes a beta distribution using Cheng's method (1978) when shape_a>1 or shape_b>1 and Berman's method (1970) otherwise
    • betaprime

      public double betaprime(double shape_a, double shape_b)
      computes a beta prime distribution
      Returns:
      1/beta(shape_a, shape_b) - 1
    • cauchy

      public double cauchy(double median, double scale)
      computes a Cauchy's distribution
      Returns:
      median + scale/tan(Π * sample); sample is provided by the PRGN
    • chisquare

      public double chisquare(long deg_freedom)
      computes a chisquare distribution
      Returns:
      ∑(i=0; i<deg_freedom; normal(0,1))
    • erlang

      public double erlang(double scale, double shape)
      computes an Erlang's distribution
      Returns:
      -scale * log ( ∏(i=0; i<shape; sample) ); sample is provided by the PRGN
    • f

      public double f(long num_deg_freedom, long den_deg_freedom)
      computes a F distribution
      Returns:
      chisquare(num_deg_freedom)/num_deg_freedom / chisquare(den_deg_freedom)/den_deg_freedom
    • gamma

      public double gamma(double scale, double shape)
      computes a gamma distribution
    • invgamma

      public double invgamma(double scale, double shape)
      computes an invgamma distribution
      Returns:
      1.0/gamma(scale, shape)
    • logistic

      public double logistic(double location, double scale)
      computes a logistic distribution
      Returns:
      location - scale * log (1/sample - 1)
    • lognormal

      public double lognormal(double mean, double variance)
      computes a lognormal distribution
      Returns:
      exp(mean + √variance * normal(0,1))
    • lognormal2

      public double lognormal2(double mean, double std_dev)
      computes a lognormal distribution
      Parameters:
      std_dev - is assumed to be the square root of the variance.
      Returns:
      exp(mean + std_dev * normal(0,1))
    • negexp

      public double negexp(double mean)
      computes a negexp distribution
      Returns:
      -mean * log (sample); where sample is provided by the PRGN
    • normal

      public double normal(double mean, double variance)
      computes a normal distribution; sample are provided by the same PRGN
      Returns:
      mean + √(variance) * cos (2Π * sample) * √(-2 * log (sample))
    • normal2

      public double normal2(double mean, double std_dev)
      computes a normal distribution; sample are provided by the same PRGN
      Parameters:
      std_dev - is assumed to be the square root of the variance.
      Returns:
      mean + std_dev * cos (2Π * sample) * √(-2 * log (sample))
    • pareto

      public double pareto(double scale, double shape)
      computes a pareto distribution; sample is provided by the PRGN
      Returns:
      scale / (sample^(1/shape))
    • tstudent

      public double tstudent(long deg_freedom)
      computes a tstudent distribution; sample is provided by the PRGN
      Returns:
      normal(0,1)/√(chisquare(deg_freedom)/deg_freedom)
    • uniform

      public double uniform(double min, double max)
      computes a uniform distribution; sample is provided by the PRGN
      Returns:
      min + (max-min) * sample
    • weibull

      public double weibull(double scale, double shape)
      computes a weibull distribution; sample is provided by the PRGN
      Returns:
      scale * (sample ^ (1/shape))