File size: 761 Bytes
04428af |
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 |
"""
normality_checks.py
Module for normality check heuristics.
"""
from typing import Tuple
def iqr_tail_heaviness(iqr: float, sd: float) -> float:
"""Return ratio R = IQR/SD for tail heaviness checking."""
return iqr / sd if sd != 0 else float("nan")
def quartile_z_scores(
mean: float,
sd: float,
q1: float,
q3: float,
) -> Tuple[float, float]:
"""Return observed z-scores for Q1 and Q3."""
if sd == 0:
return (float("nan"), float("nan"))
q1_z = (q1 - mean) / sd
q3_z = (q3 - mean) / sd
return q1_z, q3_z
def pearson_skewness(mean: float, median: float, sd: float) -> float:
"""Return Pearson's moment coefficient of skewness."""
return 3 * (mean - median) / sd if sd != 0 else float("nan")
|