Confidence Intervals
glide.confidence_intervals.clt.CLTConfidenceInterval
dataclass
Confidence interval based on the Central Limit Theorem.
Constructs a symmetric interval around the point estimate using the standard normal distribution: [mean - z * std, mean + z * std], where z is the critical value from the standard normal distribution corresponding to the target confidence level.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mean
|
float
|
The point estimate of the population mean. |
required |
std
|
float
|
The standard error (standard deviation of the estimate). |
required |
confidence_level
|
float
|
Target coverage probability, e.g. 0.95 for a 95% CI. Default is 0.95. |
0.95
|
Examples:
>>> from glide.confidence_intervals import CLTConfidenceInterval
>>> ci = CLTConfidenceInterval(mean=5.0, std=0.2, confidence_level=0.95)
>>> print(f"[{ci.lower_bound:.3f}, {ci.upper_bound:.3f}]")
[4.608, 5.392]
Source code in glide/confidence_intervals/clt.py
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
test_null_hypothesis
test_null_hypothesis(h0_value, alternative='two-sided')
Perform a one-sample z-test against a null hypothesis value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
h0_value
|
float
|
The hypothesized population mean under the null hypothesis (H0: μ = h0_value). |
required |
alternative
|
str
|
The alternative hypothesis. One of:
- |
'two-sided'
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float, float]
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in glide/confidence_intervals/clt.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
glide.confidence_intervals.bootstrap.BootstrapConfidenceInterval
dataclass
Quantile bootstrap confidence interval.
Stores the full distribution of bootstrap point estimates and derives bounds as quantiles of that distribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bootstrap_estimates
|
NDArray
|
Array of shape (B,) containing the B bootstrap point estimates. |
required |
confidence_level
|
float
|
Target coverage, e.g. 0.95 for a 95 % CI. Default is 0.95. |
0.95
|
Examples:
>>> import numpy as np
>>> from glide.confidence_intervals import BootstrapConfidenceInterval
>>> rng = np.random.default_rng(0)
>>> estimates = rng.normal(loc=5.0, scale=0.3, size=20)
>>> ci = BootstrapConfidenceInterval(bootstrap_estimates=estimates, confidence_level=0.95)
>>> print(f"[{ci.lower_bound:.3f}, {ci.upper_bound:.3f}]")
[4.453, 5.354]
Source code in glide/confidence_intervals/bootstrap.py
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
test_null_hypothesis
test_null_hypothesis(h0_value, alternative='two-sided')
Bootstrap hypothesis test against a null value.
Computes a p-value as the proportion of bootstrap estimates that are
at least as extreme as h0_value under the specified alternative.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
h0_value
|
float
|
The hypothesized population mean under the null hypothesis (H0: μ = h0_value). |
required |
alternative
|
str
|
The alternative hypothesis. One of:
- |
'two-sided'
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float, float]
|
|
Source code in glide/confidence_intervals/bootstrap.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |