#VD : (X1, X2,...Xn) ~ N (miu, sigma^2)
#(Xbar - mu)/(S/sqrt(n)) ~ Student(n - 1)

N = 10^4
Sample = rep(0,N)
for (i in 1:N){
	X = rnorm(10, 0, 1)
	Sample[i] = mean(X)/(sd(X)/sqrt(10))
}

hist(Sample, breaks = 100, freq = FALSE)
curve(dt(x, df = 9), add = TRUE, col = "red", lwd = 2)


#VD2:
N = 10^4
Sample = rep(0,N)
for (i in 1:N){
	X = rnorm(10, 0, 1)
	Sample[i] = 9*var(X)
}

hist(Sample, breaks = 100, freq = FALSE)
curve(dchisq(x, df = 9), add = TRUE, col = "red", lwd = 2)

#VD3: (X1,X2,...) ~ Ber(p)
#(P^ - p)/sqrt(p.(1-p)/n)) xx N(0,1)

N = 10^4
p = 0.9
n = 200
Sample = rep(0,N)
for (i in 1:N){
	X = rbinom(n, size = 1, prob = p)
	Sample[i] = mean(X)
}

hist(Sample, breaks = 50, freq = FALSE)
curve(dnorm(x, p, sqrt(p*(1 - p)/n)), add = TRUE, col = "red", lwd = 2)

#VD4: (X1,X2,...,Xn) ~ f
#f: u[-1,1]
#f: Exp(1)
#f; Student(5)
#(X gach - miu)/(o/sqrt(n)) xap xi N(0,1)
#(X gach - miu)/(S/sqrt(n)) xx N(0,1)

n = 5000 
N = 10^4
Sample = rep(0,N)
for (i in 1:N) {
	X = rbinom( n, size = 1, prob = p)
	Sample [i] = mean(X)
}

hist(Sample, breaks = 50, freq = FALSE)
curve(dnorm(x, p, )


#VD5: (X



Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: