mcframework.utils.autocrit#
- mcframework.utils.autocrit(confidence: float, n: int, method: str = 'auto') tuple[float, str][source]#
Select a critical value (z or t) for two-sided CIs.
Chooses between
z_crit()andt_crit()based on the requestedmethodand the sample sizen:method="z"– always use normal criticals.method="t"– always use Student t with\mathrm{df} = \max(1, n-1).method="auto"– use z ifn \ge 30, else t.
- Parameters:
- Returns:
- Raises:
ValueErrorIf
confidenceis invalid ormethodis not one of{"auto","z","t"}.
See also
mcframework.stats_engine.ci_meanUses this selector to build mean CIs.
Notes
The returned critical is intended for two-sided intervals of the form
\[\bar X \pm c \,\frac{s}{\sqrt{n}},\]where \(c\) is either \(z_{\alpha/2}\) or \(t_{\alpha/2,\;\mathrm{df}}\) with \(\mathrm{df}=\max(1, n-1)\).
Examples
>>> c, kind = autocrit(0.95, n=20, method="auto") >>> kind 't' >>> round(c, 2) 2.09 >>> c, kind = autocrit(0.95, n=50, method="auto") >>> kind 'z' >>> round(c, 2) 1.96