Äquivalent zu CHIINV (Excle)

mit matplotlib, NumPy, pandas, SciPy, SymPy und weiteren mathematischen Programmbibliotheken.
Antworten
hdamok
User
Beiträge: 4
Registriert: Freitag 7. Dezember 2018, 08:28

Hallo,

ich suche das Äquivalent zu CHIINV Funktion aus Excel.
CHIINV = Gibt Perzentile der rechtsseitigen Chi-Quadrat-Verteilung zurück.

Gruß, David
Jankie
User
Beiträge: 592
Registriert: Mittwoch 26. September 2018, 14:06

Habe das hier gefunden, weiß aber nicht ob es funktioniert:

Code: Alles auswählen

import math

def chi2P(chi, df):
    """Return prob(chisq >= chi, with df degrees of
freedom).

    df must be even.
    """
    assert df & 1 == 0
    # XXX If chi is very large, exp(-m) will underflow to 0.
    m = chi / 2.0
    sum = term = math.exp(-m)
    for i in range(1, df//2):
        term *= m / i
        sum += term
    # With small chi and large df, accumulated
    # roundoff error, plus error in
    # the platform exp(), can cause this to spill
    # a few ULP above 1.0. For
    # example, chi2P(100, 300) on my box
    # has sum == 1.0 + 2.0**-52 at this
    # point.  Returning a value even a teensy
    # bit over 1.0 is no good.
    return min(sum, 1.0)
Quelle: http://www.linuxjournal.com/files/linux ... 467s2.html

Vielleicht hilft dir das auch weiter: https://docs.scipy.org/doc/scipy/refere ... .chi2.html
Antworten