Do
Y=runif(5,0,1)
X=runif(6,0,1)
Use simulation to approximate the density functions of
The density functions of \(\mu_Y - \mu_X\)
Y=runif(5,0,1)
X=runif(6,0,1)
difference <- mean(Y)-mean(X)
u <- c(X,Y)
N=10000
d <- numeric()
for(i in 1:N){
Y=runif(5,0,1)
X=runif(6,0,1)
d[i] <- mean(Y)-mean(X)
}
mean(d);sd(d)
## [1] 0.0004398058
## [1] 0.1744461
par(mfrow=c(2,2))
qqplot(d,rnorm(N,mean(d),sd(d)),main='Q-Q Plot of d and Normal(mean(a),sd(a))')
truehist(d,main='Histgram of d and density of Normal(mean(a),sd(a))')
lines(dnorm(seq(min(d),max(d),.01),mean(d),sd(d))~seq(min(d),max(d),.01),col='red')
qqplot(d/sd(d)/sqrt(1/5+1/6),rt(N,df = 9),main='Q-Q Plot of d and t_9')
truehist(d/sd(d)/sqrt(1/5+1/6),main='Histgram of d/sd(d)/sqrt(1/5+1/6) and density of t_9')
xaxis <- seq(min(d),max(d),.01)/sd(d)/sqrt(1/5+1/6)
lines(dt(xaxis,df = 9)~xaxis,col='red')
The density functions of \(\mu_Y - \mu_X\) is approximately same as Normal(0, 0.17). The density functions of \(\cfrac{\mu_Y - \mu_X}{\sigma_{\mu_Y - \mu_X} \sqrt{1/n_X+1/n_Y}}\) is approximately same as \(t_{n_X+n_Y-2}\).
Compare them to the density of \(t_{n_X+n_Y-2}\).
Y=runif(5,0,1)
X=runif(6,0,1)
XY <- c(X,Y)
N=10000
d <- numeric()
for(i in 1:N) {
u=sample(XY)
d[i]=mean(u[1:5])-mean(u[6:11])
}
mean(d);sd(d)
## [1] -0.0002583145
## [1] 0.1640765
par(mfrow=c(2,2))
qqplot(d,rnorm(N,mean(d),sd(d)),main='Q-Q Plot of d and Normal(mean(a),sd(a))')
truehist(d,main='Histgram of d and density of Normal(mean(a),sd(a))')
lines(dnorm(seq(min(d),max(d),.01),mean(d),sd(d))~seq(min(d),max(d),.01),col='red')
qqplot(d/sd(d)/sqrt(1/5+1/6),rt(N,df = 9),main='Q-Q Plot of d/sd(d)/sqrt(1/5+1/6) and t_9')
truehist(d/sd(d)/sqrt(1/5+1/6),main='Histgram of d/sd(d)/sqrt(1/5+1/6) and density of t_9')
xaxis <- seq(min(d),max(d),.01)/sd(d)/sqrt(1/5+1/6)
lines(dt(xaxis,df = 9)~xaxis,col='red')
The permutation distribution of \(\mu_Y - \mu_X\) is approximately same as Normal(0, 0.17). The permutation distribution of \(\cfrac{\mu_Y - \mu_X}{\sigma_{\mu_Y - \mu_X} \sqrt{1/n_X+1/n_Y}}\) is approximately same as \(t_{n_X+n_Y-2}\).