randgen/distributions

Types

FloatPair = tuple[num1: float, num2: float]

Procs

proc randGaussian(mu = 0.0; sigma = 1.0; return_pari: bool): FloatPair {...}{.raises: [],
    tags: [].}

Use Box-Muller method to generate a pair of Gaussian numbers.

Wiki: https://en.wikipedia.org/wiki/Box-Muller_transform

proc randGaussian(mu = 0.0; sigma = 1.0): float {...}{.raises: [], tags: [].}

Use Box-Muller method to generate a pair of Gaussian numbers.

Wiki: https://en.wikipedia.org/wiki/Box-Muller_transform

Italian
proc randGaussianTrunc(mu = 0.0; sigma = 1.0; lb = -2.0; ub = 2.0): float {...}{.raises: [], tags: [].}
proc randGaussianTanh(mu = 0.0; sigma = 1.0; lb = -2.0; ub = 2.0): float {...}{.raises: [], tags: [].}
proc randExponential(lambda = 1.0): float {...}{.raises: [], tags: [].}

Use inverse CDF method to generate a Exponetial random numer.

Wiki: https://en.wikipedia.org/wiki/Exponential_distribution

Wiki: https://en.wikipedia.org/wiki/Inverse_transform_sampling

Italian
proc randLaplace(mu = 0.0; b = 1.0): float {...}{.raises: [], tags: [].}

Use inverse CDF method to generate a Laplace random numer.

Wiki: https://en.wikipedia.org/wiki/Laplace_distribution

Wiki: https://en.wikipedia.org/wiki/Inverse_transform_sampling

Italian
proc randCauchy(x0 = 0.0; gamma = 1.0): float {...}{.raises: [], tags: [].}

Use inverse CDF method to generate a Cauchy random numer.

Wiki: https://en.wikipedia.org/wiki/Cauchy_distribution

Wiki: https://en.wikipedia.org/wiki/Inverse_transform_sampling

proc randRayleigh(sigma = 1.0): float {...}{.raises: [], tags: [].}

Use inverse CDF method to generate a Rayleigh random numer.

Wiki: https://en.wikipedia.org/wiki/Rayleigh_distribution

Wiki: https://en.wikipedia.org/wiki/Inverse_transform_sampling

Italian
proc randGamma(k = 1.0; theta = 2.0): float {...}{.raises: [], tags: [].}

Wiki: https://en.wikipedia.org/wiki/Gamma_distribution

Italian
proc randLogNormal(mu = 0.0; sigma = 1.0): float {...}{.raises: [], tags: [].}

Wiki: https://en.wikipedia.org/wiki/Log-normal_distribution

Method: first generate a Gaussian random number, and then take it to exp(.) function.

Italian
proc randChi2(df = 1): float {...}{.raises: [], tags: [].}

Wiki: https://en.wikipedia.org/wiki/Chi-square_distribution

Method: The chi-square distribution (with d.o.f. df) is a special case of gamma distribution (Gamma(df/2, 2))

Italian
proc randF(df1 = 1; df2 = 1): float {...}{.raises: [], tags: [].}

Wiki: https://en.wikipedia.org/wiki/F-distribution

Method: F-distribution is defined as ratio of two independent and scaled chi-squared random variables.

Italian
proc randStudent(df = 1): float {...}{.raises: [], tags: [].}

Wiki: https://en.wikipedia.org/wiki/Student%27s_t-distribution

Method: Student t distribution is defined as ratio of standard normal random number devided by a Chi2 random numer (with d.o.f of df)

Italian
proc randBeta(alpha = 0.5; beta = 0.5): float {...}{.raises: [], tags: [].}

Wiki: https://en.wikipedia.org/wiki/Beta_distribution

Italian
proc randLogistic(mu = 5.0; s = 2.0): float {...}{.raises: [], tags: [].}

Use inverse CDF method to generate a Logistic random numer.

Wiki: https://en.wikipedia.org/wiki/Logistic_distribution

Wiki: https://en.wikipedia.org/wiki/Inverse_transform_sampling

Italian
proc randWeibull(lambda = 1.0; k = 0.5): float {...}{.raises: [], tags: [].}

Use inverse CDF method to generate a Weibull random numer.

Wiki: https://en.wikipedia.org/wiki/Weibull_distribution

Wiki: https://en.wikipedia.org/wiki/Inverse_transform_sampling

proc randBinomial(p = 0.5; n = 1): int {...}{.raises: [], tags: [].}

Use a truncated normal distribution to approximate the Binomial distribution.

Wiki: https://en.wikipedia.org/wiki/Binomial_distribution

Italian
proc randPoisson(lambda = 1.0): int {...}{.raises: [], tags: [].}

Wiki: https://en.wikipedia.org/wiki/Poisson_distribution

Italian