Description Usage Arguments Value Examples
To produce a random Bernoulli number(which is 1 with the probability of p and zero with the probability of 1-p) this function produce one random number between 0 and 1 with uniform distribution (For this purpose we already have a dugen function). Then the function returns one if this number is less than p and zero otherwise. (for the uniform distribution with minimum a and maximum b, the probability of variable X being within a specified interval is the ratio of the interval’s length to the subtraction of a from b, so if 0<X<1, P(X <P) = (p-0)/(1-0) = p, hence we return a 1 if(X<p) and zero otherwise)
1 | Brgen(x)
|
p (the probability of the bernoulli variable being a one)
a Bernoulli random variable is returned.
1 2 3 | a <- brgen(0.7)
a
visualbrgen(a)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.