[−][src]Function behrens_fisher::confidence_interval
pub fn confidence_interval(
sig_level: f64,
x: Stats,
y: Stats
) -> Result<f64, Error>
A confidence interval for y.mean - x.mean
. This function returns the
half-width of the confidence interval, ie. the i
in y.mean - x.mean ± i
.
Given two normally distributed populations X ~ N(μ_x, σ²_x) and Y ~ N(μ_y, σ²_y), Y-X is distributed as N(μ_y - μ_x, σ²_x + σ²_y).
We have a sample from X and a sample from Y and we want to use these to estimate μ_y - μ_x.
Variance of the difference between the means
We have an estimate of μ_(Y-X) - namely, ̄y - ̄x, and we want to know the variance of that estimate. For this we can use the sum of the variances of ̄x and ̄y, which gives s²_x/n_x + s²_y/n_y.
Degrees of freedom
The degrees of freedom for s² is n-1. To compute the pooled degrees of freedom of the linear combination s²_x/n_x + s²_y/n_y, we use the Welch–Satterthwaite equation.