1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use ;
/// Calculates the required sample size for a test of proportions.
///
/// This function computes the necessary sample size to detect a minimum detectable difference
/// in proportions for a given alpha, power, and expected proportions.
///
/// # Arguments
///
/// * `p1` - The expected proportion in the first group.
/// * `p2` - The expected proportion in the second group.
/// * `alpha` - The significance level (e.g., 0.05 for a 95% confidence interval).
/// * `power` - The desired statistical power (e.g., 0.80 for 80% power).
///
/// # Returns
///
/// The estimated sample size required to achieve the specified power and significance level.
///
/// # Example
/// ```rust
/// use hypors::proportion::prop_sample_size;
///
/// let p1 = 0.4; // Expected proportion in group 1
/// let p2 = 0.5; // Expected proportion in group 2
/// let alpha = 0.05; // 5% significance level
/// let power = 0.80; // 80% power
///
/// let sample_size = prop_sample_size(p1, p2, alpha, power);
/// println!("Required sample size: {}", sample_size);
/// ```