Coins - BINOMIAL DISTRIBUTION.math
Heads or Tails?
start with the binomial probability distribution.
also, Pascal's triangle has the answers for the number of ways it can happen.
example: Probability of getting 5 heads in 10 flips? Using a fair coin.
Row 10 is this: 1,10,45,120,210,252,210,120,45,10,1 (row highlighted in below photo)
it means this is how many Heads there are. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 or 10 (heads or successes)
the 6th element in the row = 252 ways.
the probability is then:
252 / 2^10 or
252 / 1024 or about 24.6%
Pascal's triangle to Row 15
1r. using R for the number of ways (where order does not matter) from N to choose X.
choose(10,5) means we have 10 and want to choose 5
in other words 10 choose 5
2r. R code for the binomial distribution.
for the probability mass function (pmf). exactly X Heads (successes) in N flips.
call function with example: data(10, 1/2, 0, 10)
data(number of trials, probability of success at each trial, min success, max success)
example: data(10, 1/2, 5, 5) will return the probability for just 5 successes
cumulative probability has been added for a range
3r. R code for the cumulative distribution function and inverse (at least X) .
exactly X Heads or less (successes) in N flips. (pmf)
call function with example: data(10, 1/2, 0, 10)
data(number of trials, probability of success at each trial, min success, max success)
example: data(10, 1/2, 5, 5) will return the probability for just 5 successes or less
4r. R code to produce up to row x for Pascal's triangle rows.
Index starts at 1 which is row 0
5r. R code to produce a specific row for Pascal's triangle.
Returns a matrix showing the number of ways for 'choose k' from n