# BinomialDistibution.R # Calculating binomial probabilities is easy in R. The function 'binom.test' takes in # three variables: (1) K, the number of sucessful oucomes, (2) N, the total number of trials, # and (3) P, the probability of a succesful outcome on any given trial. # # A fourth argument can be 'alternative = "less"', or 'alternative = "greater"', depending on # whether you want Pr(xk) # Example: Given 10 flips of a fair 50/50 coin, what is the probability of obtaining 6 or more heads? out <- binom.test(6,10,.5, alternative = "greater") # The result can be found in the field 'p.value': print(out\$p.value) # Example: If you guess on a 20 question multiple choice test where each question has 5 possible # answers, what is the probability of getting 4 or less correct? out <- binom.test(4,20,1/5, alternative = "less") print(out\$p.value) # Example: If a basketball player has a 2 out 3 chance of making a free throw on any given try, # and all tries are independent, what is the probability of making 7 or more out of 10? out <- binom.test(7,10,2/3, alternative = "greater") print(out\$p.value)