I have a program that simulates a fair dice 100 times. Using this program I need to have a bell curve over the histogram showing normal/Gaussian distribution. In my code The variable representing the outcome of the experiment is z. The definition of the bell curve contains two parameters: ave determines where on the z-axis the curve must have a maximum and sig determines the width of the peak.
set.seed(123)
x <- sample(1:6, size=100, replace = TRUE)
hist(x,
main="100 fair rolls",
xlab = "Dice Result",
ylab = "Probability",
xlim=c(0.5,6.5),
breaks=-1:100+.5,
prob=TRUE )
Gaussian distribution equation I have so far:
bell<-function(z,ave,sig){
exp(-(z-ave)^2/(2*sig))/sqrt(2*pi*sig)
}
points<-0:600
lines(points,bell(points,350,292))