Infermath logo


Open source of math

Probability in R: Discrete Random Variables

  1. Bernoulli distribution (2 tutorials)
  2. Binomial distribution (3 tutorials)
  3. Geometric distribution (3 tutorials)
  4. Borel-Cantelli lemma (4 tutorials)

Binomial distribution

Binomial distribution is an extension of Bernoulli ditribution. It models the number of successful trials in a multiple Bernoulli.

Part 1

We define binomial distribution and generate it using R. We familiarize ourselves with histogram in R.
R commands and functions:
  • hist(v) - represents data from vector v in a histogram
  • rbinom(n,m,p) - generates n draws from binomial distribution distribution with parameters m and p

Part 2

In this episode we derive the probability of each outcome in binomial distribution. We show the probabilities add up to 1 using set theory, polynomials and Pascal's triangle.
Mathematical formulas:

Part 3

In this video we are comparing the probability distribution of binomial random variables to simulation in R. We learn how to generate vectors and matrices, use the for loop and bar plot in R.
R commands and functions:
  • 1:n - generates a vector of n integers
  • matrix(nrow=n,ncol=m) - generates empty matrix of n rows and m columns
  • for(i in v){do} - repeats do command for i taking all the values from vector v