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
46
47
48
49
50
51
52
53
54
55
56
use crateTailType;
use ;
/// Calculates the required sample size for a one-sample Z-test.
///
/// This function computes the necessary sample size to detect a minimum detectable effect size
/// for a given alpha, power, and standard deviation.
///
/// # Arguments
///
/// * `effect_size` - The minimum detectable effect size.
/// * `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).
/// * `std_dev` - The population standard deviation (or a reasonable estimate).
/// * `tail` - The type of tail (left, right, or two) for the test.
///
/// # Returns
///
/// The estimated sample size required to achieve the specified power and significance level.
///
/// # Example
/// ```rust
/// use hypors::z::z_sample_size;
/// use hypors::common::TailType;
///
/// let effect_size = 0.5;
/// let alpha = 0.05; // 5% significance level
/// let power = 0.80; // 80% power
/// let std_dev = 1.0;
/// let tail = TailType::Two; // Two-tailed test
///
/// let sample_size = z_sample_size(effect_size, alpha, power, std_dev, tail);
/// println!("Required sample size: {}", sample_size);
/// ```