mu=100
sigma=10
x=seq(70,130,length=200)
y=dnorm(x,mu,sigma)
plot(x,y,type="l",col="red",
main=paste("Mean = ",mu,", Standard Deviation = ",sigma),
xlab="x",
ylab="p")

n=10000
mu=100
sigma=10
x=rnorm(n,mu,sigma)
hist(x,prob=TRUE,xlim=c(70,130))

x=rnorm(5,100,10)
x
## [1] 108.07 84.84 118.72 91.47 95.25
mu5=mean(x)
mu5
## [1] 99.67
x=rnorm(5,100,10)
x
## [1] 97.13 98.36 94.75 97.03 86.13
mu5=mean(x)
mu5
## [1] 94.68
xbar_5=replicate(6,mean(rnorm(5,100,10)))
xbar_5
## [1] 96.83 100.91 91.32 105.88 94.81 101.90
xbar_5=replicate(500,mean(rnorm(5,100,10)))
mu_5=round(mean(xbar_5,2))
sd_5=round(sd(xbar_5),2)
hist(xbar_5,
prob=TRUE,
main=paste("mean = ",mu_5,", sd = ",sd_5))

par(mfrow=c(1,2))
x=rnorm(10000,100,10)
hist(x,
prob=TRUE,
breaks=12,
xlim=c(70,130),
main="mean = 100, sd=10")
xbar_5=replicate(500,mean(rnorm(5,100,10)))
mu_5=round(mean(xbar_5,2))
sd_5=round(sd(xbar_5),2)
hist(xbar_5,
prob=TRUE,
breaks=12,
xlim=c(70,130),
main=paste("mean = ",mu_5,", sd = ",sd_5))

par(mfrow=c(3,2))
xbar_5=replicate(500,mean(rnorm(5,100,10)))
mu_5=round(mean(xbar_5,2))
sd_5=round(sd(xbar_5),2)
hist(xbar_5,
prob=TRUE,
breaks=12,
xlim=c(70,130),
main=paste("mean = ",mu_5,", sd = ",sd_5))
xbar_10=replicate(500,mean(rnorm(10,100,10)))
mu_10=round(mean(xbar_10,2))
sd_10=round(sd(xbar_10),2)
hist(xbar_10,
prob=TRUE,
breaks=12,
xlim=c(70,130),
main=paste("mean = ",mu_10,", sd = ",sd_10))
xbar_20=replicate(500,mean(rnorm(20,100,10)))
mu_20=round(mean(xbar_20,2))
sd_20=round(sd(xbar_20),2)
hist(xbar_20,
prob=TRUE,
breaks=12,
xlim=c(70,130),
main=paste("mean = ",mu_20,", sd = ",sd_20))
xbar_30=replicate(500,mean(rnorm(30,100,10)))
mu_30=round(mean(xbar_30,2))
sd_30=round(sd(xbar_30),2)
hist(xbar_30,
prob=TRUE,
breaks=12,
xlim=c(70,130),
main=paste("mean = ",mu_30,", sd = ",sd_30))
xbar_40=replicate(500,mean(rnorm(40,100,10)))
mu_40=round(mean(xbar_40,2))
sd_40=round(sd(xbar_40),2)
hist(xbar_40,
prob=TRUE,
breaks=12,
xlim=c(70,130),
main=paste("mean = ",mu_40,", sd = ",sd_40))
xbar_50=replicate(500,mean(rnorm(50,100,10)))
mu_50=round(mean(xbar_50,2))
sd_50=round(sd(xbar_50),2)
hist(xbar_50,
prob=TRUE,
breaks=12,
xlim=c(70,130),
main=paste("mean = ",mu_50,", sd = ",sd_50))

par(mfrow=c(1,1))