b0f34cdfd3ec8e41521cfd1b4a19c8dabb51fbbf,scipy/stats/_ksstats.py,,_kolmogn_p,#Any#Any#,498

Before Change


    def _kk(_x):
        return kolmogn(n, _x)

    pdf = scipy.misc.derivative(_kk, x, dx=delta, order=5)

    return pdf


def _kolmogni(n, p, q):
    Compute the PPF/ISF of kolmogn.

After Change



    x must be of type float, n of type integer.
    
    if np.isnan(n):
        return n  // Keep the same type of nan
    if int(n) != n or n <= 0:
        return np.nan
    if x >= 1.0 or x <= 0:
        return 0
    t = n * x
    if t <= 1.0:
        // Ruben-Gambino: n!/n^n * (2t-1)^n -> 2 n!/n^n * n^2 * (2t-1)^(n-1)
        if t <= 0.5:
            return 0.0
        if n <= 140:
            prd = np.prod(np.arange(1, n) * (1.0 / n) * (2 * t - 1))
        else:
            prd = np.exp(_log_nfactorial_div_n_pow_n(n) + (n-1) * np.log(2 * t - 1))
        return prd * 2 * n**2
    if t >= n - 1:
        // Ruben-Gambino : 1-2(1-x)**n -> 2n*(1-x)**(n-1)
        return 2 * (1.0 - x) ** (n-1) * n
    if x >= 0.5:
        return 2 * scipy.stats.ksone.pdf(x, n)

    // Just take a small delta.
    // Ideally x +/- delta would stay within [i/n, (i+1)/n] for some integer a.
    // as the CDF is a piecewise degree n polynomial.
    // It has knots at 1/n, 2/n, ... (n-1)/n
    // and is not a C-infinity function at the knots
    delta = x / 2.0**16
    delta = min(delta, x - 1.0/n)
    delta = min(delta, 0.5 - x)

    def _kk(_x):
        return kolmogn(n, _x)

    return scipy.misc.derivative(_kk, x, dx=delta, order=5)


def _kolmogni(n, p, q):
    Computes the PPF/ISF of kolmogn.
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 8

Instances


Project Name: scipy/scipy
Commit Name: b0f34cdfd3ec8e41521cfd1b4a19c8dabb51fbbf
Time: 2020-02-15
Author: pvanmulbregt@users.noreply.github.com
File Name: scipy/stats/_ksstats.py
Class Name:
Method Name: _kolmogn_p


Project Name: scipy/scipy
Commit Name: b0f34cdfd3ec8e41521cfd1b4a19c8dabb51fbbf
Time: 2020-02-15
Author: pvanmulbregt@users.noreply.github.com
File Name: scipy/stats/_ksstats.py
Class Name:
Method Name: _kolmogn


Project Name: ContextLab/hypertools
Commit Name: ab4c3743ec1c77d67ddede9fb400b55b3778e39b
Time: 2016-12-17
Author: andrew.heusser@gmail.com
File Name: python/hypertools/reduce.py
Class Name:
Method Name: reducePCA


Project Name: ContextLab/hypertools
Commit Name: 1430ab58648b4bd189f232ae2acc8b86ce2fd9aa
Time: 2016-12-17
Author: andrew.heusser@gmail.com
File Name: python/hypertools/reduce.py
Class Name:
Method Name: reducePCA