Description
Exercise 1

Generate 100 experiments of flipping 10 coins, each with 30% probability.

What is the most common number? Why?


Size= number of coin flips



p= the probability of seeing one head in a coin flip



Random variable denotes number of heads.


~ 10, . 5

Pr = 5 ?
Simulation:

Repeat this experiment 100,000 times: “number of draws=100,000”

flips < rbinom(100000,10,.5)

flips contains 100000 numbers, each between 0 and 10 (number of heads).

mean(flips == 5), returns percentage of number “5” among 100000 numbers.

dbinom(5,10,.5) returns probability of seeing 5 heads out of 10 tosses, for a fair coin using exact calculation.

Note that if you rerun it, you will get the same result.

As you can see, the result of exact calculation is 0.2460938 which is very close to the result of our simulation 0.24769
dbinom(k,10,.5) returns Pr = = ( )

If you flip 10 coins each with a 30% probability of coming up heads, what is the probability exactly 2 of them are heads?

Compare your simulation with the exact calculation.

For exercise 2,

Part a) use 10000 experiments and report the result.

Part b) use 100000000 experiments and report the result.

Compare the result of part a and part b, with the exact calculation. What is your conclusion?
If ~ 10, . 5 , what is the E[ ]? using calculation E = 5.

Simulation: run the experiment 100,000 times.

flips < rbinom (100000, 10, .5 )

mean (flips): the average number of heads
Result of simulation is close to 5
If ~ 100, . 2 , what is the E[ ]? using calculation E = 20.

Simulation: run the experiment 100,000 times.

flips < rbinom (100000, 100, .2 )

mean (flips): the average number of heads
Result of simulation is close to 20

What is the expected value of a binomial distribution where 25 coins are flipped, each having a 30% chance of heads?

Compare your simulation with the exact calculation.
If ~ 10, . 5 , what is the Var[ ]? using calculation Var =2.5.

Simulation: run the experiment 100,000 times.

X < rbinom (100000, 10, .5 )

var(X): the variance
Result of simulation is close to 2.5
If ~ 100, . 2 , what is the Var[ ]? using calculation Var = 16.

Simulation: run the experiment 100,000 times.

X < rbinom (100000, 100, .2 )

var(X): the variance
Result of simulation is close to 16

What is the variance of a binomial distribution where 25 coins are flipped, each having a 30% chance of heads?

Compare your simulation with the exact calculation.