Basically given the CDF F of some distribution (say, Poisson), you can
generate random numbers from the Poisson distribution by doing:
u = rand # uniformely generated random number
y = Finv(u)
Libra
If you are comfortable with R, you can use RSRuby (http://
web.kuicr.kyoto-u.ac.jp/~alexg/rsruby/) to generate numbers from any
its distribution functions. For example, extracting 10 numbers from a
normal distribution with mean 0:
The default R stats package has the following distributions built in
and you can use any R library to add more (I couldn’t see Bernoulli
in this list, but maybe it has an alternative name?):
Beta(stats) The Beta Distribution
Binomial(stats) The Binomial Distribution
Cauchy(stats) The Cauchy Distribution
Chisquare(stats) The (non-central) Chi-Squared Distribution
Exponential(stats) The Exponential Distribution
FDist(stats) The F Distribution
GammaDist(stats) The Gamma Distribution
Geometric(stats) The Geometric Distribution
Hypergeometric(stats) The Hypergeometric Distribution
Logistic(stats) The Logistic Distribution
Lognormal(stats) The Log Normal Distribution
Multinomial(stats) The Multinomial Distribution
NegBinomial(stats) The Negative Binomial Distribution
Normal(stats) The Normal Distribution
Poisson(stats) The Poisson Distribution
SignRank(stats) Distribution of the Wilcoxon Signed Rank
Statistic
TDist(stats) The Student t Distribution
Tukey(stats) The Studentized Range Distribution
Uniform(stats) The Uniform Distribution
Weibull(stats) The Weibull Distribution
Wilcoxon(stats) Distribution of the Wilcoxon Rank Sum Statistic
ecdf(stats) Empirical Cumulative Distribution Function
survreg.distributions(survival)
Parametric Survival Distributions
If you are comfortable with R, you can use RSRuby (http://
web.kuicr.kyoto-u.ac.jp/~alexg/rsruby/) to generate numbers from
any its distribution functions.
A quick bit of googling found the missing Bernoulli distribution
function:
cauchy exponential power poisson etc. also available
ruby - making maths easy
There is also RSRuby, a way of calling the R libraries, including their
probability distribution routines, from Ruby. I don’t know anything
about the ones in GSL, but I know the algorithms in R are first-rate,
and I wouldn’t code my own no matter how bored I got.