R入門5
We flip the coin 30 times and observe 10 head. We can use R to tell us the probability of getting 10 or fewer heads using the pbinom function.
pbinom(10, size=30, prob=0.5) 0.0493685733526945
The way we determined the probability of getting exactly 10 heads is by using the probability formula for Bernoulli trials. The probability of getting k successes in n trials is equal to:
$$\binom{n}{k}p^k(1-p)^{n-k}$$
rnorm is the R function that simulates random variates having a specified normal distribution.