🛠️ToolsShed

Z-Wert-Rechner

Berechnen Sie Z-Werte, Perzentilränge und Wahrscheinlichkeiten der Normalverteilung.

Häufig gestellte Fragen

Code-Implementierung

import math

def erf(x: float) -> float:
    """Abramowitz & Stegun approximation of the error function."""
    sign = 1 if x >= 0 else -1
    x = abs(x)
    a1, a2, a3, a4, a5 = 0.254829592, -0.284496736, 1.421413741, -1.453152027, 1.061405429
    p = 0.3275911
    t = 1.0 / (1.0 + p * x)
    y = 1.0 - (((((a5 * t + a4) * t) + a3) * t + a2) * t + a1) * t * math.exp(-x * x)
    return sign * y

def normal_cdf(z: float) -> float:
    """Cumulative distribution function of the standard normal."""
    return 0.5 * (1 + erf(z / math.sqrt(2)))

def z_score(value: float, mean: float, std_dev: float) -> float:
    """Calculate Z-score: how many SDs from the mean."""
    if std_dev <= 0:
        raise ValueError("Standard deviation must be positive")
    return (value - mean) / std_dev

# Example
x, mu, sigma = 75, 70, 5
z = z_score(x, mu, sigma)
prob = normal_cdf(z)
print(f"Z-score: {z:.4f}")          # 1.0000
print(f"Percentile: {prob*100:.2f}th")  # 84.13th
print(f"Probability: {prob:.6f}")    # 0.841345

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.