java.lang.Object
de.grogra.blocks.arrangeBlock.Distributions
offers several discrete and continuous distributions all seeded by a common
well-spaced pseudo random number generator (PRNG).
-
Constructor Summary
ConstructorDescriptionThe seed is automatically provided by a well-spacedSeedGenerator
Distributions
(long seed) The seed is manually setThis constructor allows for manually specially the continous generator shared to compute the distribution function. -
Method Summary
Modifier and TypeMethodDescriptionlong
bernoulli
(double prob) computes a Bernoulli's distributiondouble
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) otherwisedouble
betaprime
(double shape_a, double shape_b) computes a beta prime distributionlong
binomial
(double prob, int trials) computes a binomial distributiondouble
cauchy
(double median, double scale) computes a Cauchy's distributiondouble
chisquare
(long deg_freedom) computes a chisquare distributiondouble
erlang
(double scale, double shape) computes an Erlang's distributiondouble
f
(long num_deg_freedom, long den_deg_freedom) computes a F distributiondouble
gamma
(double scale, double shape) computes a gamma distributionlong
geometric
(double prob) computes a geometric distributiondouble
invgamma
(double scale, double shape) computes an invgamma distributiondouble
logistic
(double location, double scale) computes a logistic distributiondouble
lognormal
(double mean, double variance) computes a lognormal distributiondouble
lognormal2
(double mean, double std_dev) computes a lognormal distributiondouble
negexp
(double mean) computes a negexp distributiondouble
normal
(double mean, double variance) computes a normal distribution; sample are provided by the same PRGNdouble
normal2
(double mean, double std_dev) computes a normal distribution; sample are provided by the same PRGNdouble
pareto
(double scale, double shape) computes a pareto distribution; sample is provided by the PRGNlong
pascal
(double prob, int successes) computes a Pascal's distributionlong
poisson
(double mean) computes a poisson distributiondouble
tstudent
(long deg_freedom) computes a tstudent distribution; sample is provided by the PRGNdouble
uniform
(double min, double max) computes a uniform distribution; sample is provided by the PRGNdouble
weibull
(double scale, double shape) computes a weibull distribution; sample is provided by the PRGN
-
Constructor Details
-
Distributions
public Distributions()The seed is automatically provided by a well-spacedSeedGenerator
-
Distributions
public Distributions(long seed) The seed is manually set -
Distributions
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))
-