On Thu, Apr 9, 2009 at 17:34, ANJAN PURKAYASTHA
<anjan.purkayas...@gmail.com> wrote:
> I need a Bernoulli random number generator which takes as inputs: a value
> for p(1) (probability of choosing a "1") and the number of trials and
> outputs a series of 0s and 1s according to the model B(p(1)).
> Any thoughts on which module I need to use?
snip

When you need something the first place to look is CPAN[1].  The
Math::GSL[2] module has a function sounds like it fits your needs:

gsl_ran_bernoulli($r, $p) - This function returns either 0 or 1, the
result of a Bernoulli trial with probability $p. The probability
distribution for a Bernoulli trial is, p(0) = 1 - $p and p(1) = $p. $r
is a gsl_rng structure.

gsl_ran_bernoulli_pdf($k, $p) - This function computes the probability
p($k) of obtaining $k from a Bernoulli distribution with probability
parameter $p, using the formula given above.

1. http://search.cpan.org/
2. http://search.cpan.org/dist/Math-GSL/lib/Math/GSL/Randist.pm


-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to