Write a program to carry out the following experiment. A coin is tossed 100 times and the number of heads that turn up is recorded. This experiment is then repeated 1000 times. Have your program plot a bar graph for the proportion of the 1000 experiments in which the number of heads is n, for each n in the interval [35, 65]. Does the bar graph look as though it can be fit with a normal curve?
x = rep(0, 31)
y = rep(0, 31)
for(i in 35:65){
x[i - 34] = i
y[i - 34] = length(which(heads == i))
}
results <- data.frame(n = x, heads = y)
ggplot(data=results, aes(x=n, y=heads)) +
geom_bar(stat="identity", fill="steelblue") +
labs( title="1000 Simulations of 100 Coin Tosses", x= "Heads", y = "No. of times coin face is ") +
theme_minimal()The above graph isnโt quite skewed and it is more or less symmetrical resulting in a continuos distribution similar to a bell-shaped curve. The graph does have a normal curve that may be fitted to this graph.