pub fn welch_alt_hyp_ci(
moments_x: &SampleMoments,
moments_y: &SampleMoments,
alt_hyp: AltHyp,
alpha: f64,
) -> Result<Ci, StatsError>Expand description
Welch’s confidence interval for the difference of means (μ(X) - μ(Y)) of two distributions.
Arguments:
moments_x: first sample’s moments struct.moments_y: second sample’s moments struct.alt_hyp: alternative hypothesis.alpha: confidence level =1 - alpha.
§Errors
Returns an error in any of the following conditions:
moments_x.n() <= 1.moments_y.n() <= 1.moments_x.stdev() == 0ANDmoments_y.stdev() == 0.alphanot in interval(0, 1).
Examples found in repository?
examples/aok.rs (line 29)
10fn main() {
11 let x = [14., 15., 15., 15., 16., 18., 22., 23., 24., 25., 25.];
12 let y = [
13 10., 12., 14., 15., 18., 22., 24., 27., 31., 33., 34., 34., 34.,
14 ];
15
16 let moments_x = SampleMoments::from_slice(&x);
17 let moments_y = SampleMoments::from_slice(&y);
18 let alt_hyp = AltHyp::Gt;
19
20 {
21 println!("*** Ok scenario:");
22
23 let alpha = 0.05;
24
25 // Welch function calls below return Ok prior to invocation of aok().
26
27 let p = welch_p(&moments_x, &moments_y, alt_hyp).aok();
28 println!("p={p}");
29 let ci = welch_alt_hyp_ci(&moments_x, &moments_y, alt_hyp, alpha).aok();
30 println!("ci={ci:?}");
31 let test_res = welch_test(&moments_x, &moments_y, alt_hyp, alpha).aok();
32 println!("test_res={test_res:?}");
33 }
34
35 {
36 println!("*** Err scenario:");
37
38 let alpha = 1.0;
39
40 // Welch function calls below return Err prior to invocation of aok().
41
42 let p = welch_p(&moments_x, &SampleMoments::default(), alt_hyp).aok();
43 println!("p={p}");
44 let ci = welch_alt_hyp_ci(&moments_x, &moments_y, alt_hyp, alpha).aok();
45 println!("ci={ci:?}");
46 let test_res = welch_test(&moments_x, &moments_y, alt_hyp, alpha).aok();
47 println!("test_res={test_res:?}");
48 }
49}