Overview | Package | Class | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.grogra.blocks.arrangeBlock
Class Distributions

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

    public class Distributions

extends java.lang.Object

offers several discrete and continuous distributions all seeded by a common well-spaced pseudo random number generator (PRNG).

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

Method Summary
`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 Detail

### Distributions

    public Distributions()

  The seed is automatically provided by a well-spaced `SeedGenerator`

### Distributions

    public Distributions(ContinuousGenerator gen)

  This constructor allows for manually specially the continous generator shared to compute the distribution function.

### Distributions

    public Distributions(long seed)

  The seed is manually set

Method Detail

### bernoulli

    public long bernoulli(double prob)

  computes a Bernoulli's distribution

  Returns:
    1 iif sample ≤ prob, 0 otherwise; sample is provided by the PRGN

### 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

### binomial

    public long binomial(double prob,
                         int trials)

  computes a binomial distribution

  Returns:
    ∑(i=0; i<trials-1; bernoulli(prob))

### 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

### geometric

    public long geometric(double prob)

  computes a geometric distribution

  Returns:
    ⌈ log(sample)/log(1-prob) ⌉; sample is provided by the PRGN

### 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))

### 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)

### 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))

Overview | Package | Class | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD