Definition

It is a specific type of Sampling Distribution

Let 𝑋 be a probability function 𝑓(𝑥) and 𝑌 the probability function of 𝑓(𝑦), then same as with the Sampling Distribution of the Mean we have:

𝐸(𝑋)=𝜇𝑋, Var(𝑋)=𝜎2𝑋𝑛,𝐸(𝑌)=𝜇𝑌, Var(𝑌)=𝜎2𝑌𝑛

Therefore we can get:

𝐸(𝑋𝑌)=𝜇𝑋𝜇𝑌Var(𝑋𝑌)=𝜎2𝑋𝑛+𝜎2𝑌𝑚

Normal Approximation

For a sufficiently large 𝑛 and 𝑚, 𝑋 and 𝑌 are distributted as normal distributions. Then 𝑋𝑌 also

𝑋𝑌=𝑁((((𝜇𝑋𝜇𝑌,𝜎2𝑋𝑛+𝜎2𝑌𝑚))))𝑍=(𝑋𝑌)(𝜇𝑋𝜇𝑌)𝜎2𝑋𝑛+𝜎2𝑌𝑚

Solution Methods

Standard Deviations Known

𝑇=(̄𝑋1̄𝑋2)(𝜇1𝜇2)𝑆2𝑝(1𝑛1+1𝑛2)𝑆2𝑝=(𝑛11)𝑆21+(𝑛21)𝑆22𝑛1+𝑛22

In R:

pnorm(x, mu1 − mu2, sqrt(sd1^2/n1 + sd2^2/n2))

Standard Deviations Unknown but equal

𝑇(𝑛1)=𝑋𝜇𝑆/𝑛

In R:

df  <- n1 + n2 - 2
Sp  <- sqrt(((n1-1)*S1^2 + (n2-1)*S2^2) / df)
 
t_val <- ((xbar1-xbar2) - (mu1-mu2)) / (Sp*sqrt(1/n1+1/n2))
pt(t_val, df=df)

Standard Deviations Unknown and different

𝑇=(̄𝑋1̄𝑋2)(𝜇1𝜇2)𝑆21𝑛1+𝑆22𝑛2𝑣=(𝑆21𝑛1+𝑆22𝑛2)2(𝑆21𝑛1)2𝑛11+(𝑆22𝑛2)2𝑛21

In R:

num_df <- (s1^2/n1 + s2^2/n2)^2
den_df <- ((s1^2/n1)^2 / (n1 - 1)) + ((s2^2/n2)^2 / (s2 - 1))
df <- num_df / den_df
 
diff_observed <- xbar1 - xbar2
mean_theoretical <- mu1 - mu2
stderr <- sqrt(s1^2/n1 + s2^2/n2)
 
t_val <- (diff_observed - mean_theoretical) / stderr
pt(t_val, df = df)