(g) Compute the variance in the outcome of throwing the above loaded dice.
Write a program that does the experiment in part (g) above 105 times, and plot the probability distribution of outcomes.
part g)
Required R code:
set.seed(100)
dice = c(1,1,2,3,4,5)
n = 105
outcomes = sample( dice, n, TRUE )
m = mean(outcomes)
cat('mean is ', m)
v = mean( outcomes^2 ) - mean( outcomes )^2
cat('variance is ', v)
hist( outcomes )
OUTPUT :
mean is 2.752381
variance is 2.224399
Get Answers For Free
Most questions answered within 1 hours.