Use knitr to produce at least 3 examples
##randomly generate 100 numbers from the normal distribution(with mean=0,sd=1) rs=rnorm(100,mean=0,sd=1) ##plot the random numbers plot(rs)
we can get the $\bar{rs}=$ r mean(rs)
and the variance $S^2=$ r var(rs)
.
##generate 100 random numbers from the discrete distribution with prob=c(0.2,0.3,0.5) x=sample(1:3,100,replace=TRUE,prob=c(0.2,0.3,0.5)) ##table the 100 numbers xt=table(x) xt
and the relative frequency of 1,2,3 are r xt/100
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.