R - Binomial Distribution

> Procedural Languages > R

1 - About

3 - Function

3.1 - Density

The binomial distribution with size = n and prob = p has density

p(x) = choose(n, x) p^x (1-p)^(n-x)

for x = 0, …, n

where:

Advertising

3.2 - Cumulative

To find the probability of having k or less correct answers, we can plot a cumulative distribution.

plot(pbinom(0:40, size=20, prob=0.5) )
plot(pbinom(0:40, size=20, prob=0.7) )
plot(pbinom(0:40, size=40, prob=0.5) )

4 - Example

4.1 - Biased coin

The biased coin example of the Binomial Distribution in R

require(graphics)
dbinom(0:5, size=6, prob=0.3)
[1] 0.117649 0.302526 0.324135 0.185220 0.059535 0.010206

where:

  • 0:5 is a vector representing k (the trial index)
  • size is n, the number of trial
  • prob is the probability of a success trial

5 - Documentation / Reference

Advertising
lang/r/binomial_distribution.txt · Last modified: 2017/02/12 21:02 by gerardnico