neuroprob/utils/stats.py
def KS_statistics(quantiles, alpha=0.05, alpha_s=0.05):
    """
    Kolmogorov-Smirnov statistics using quantiles.
    """
    samples = quantiles.shape[0]
    assert samples > 1
    
    q_order = np.append(np.array([0]), np.sort(quantiles))
    ks_y = np.arange(samples+1)/samples - q_order

    # dispersion scores
    T_KS = np.abs(ks_y).max()
    
    z = q_to_Z(quantiles)
    T_DS = np.log((z**2).mean()) + 1/samples + 1/3/samples**2
    T_DS_ = T_DS/np.sqrt(2/(samples-1)) # unit normal null distribution
    
    sign_KS = np.sqrt(-0.5*np.log(alpha)) / np.sqrt(samples)
    sign_DS = sps.erfinv(1-alpha/2.)*np.sqrt(2) * np.sqrt(2/(samples-1))
    #ref_sign_DS = sps.erfinv(1-alpha_s/2.)*np.sqrt(2)
    #T_DS /= ref_sign_DS
    #sign_DS /= ref_sign_DS
    
    p_DS = 2.*(1-scstats.norm.cdf(T_DS_))
    p_KS = np.exp(-2*samples*T_KS**2)
    return T_DS, T_KS, sign_DS, sign_KS, p_DS, p_KS

    Kolmogorov-Smirnov statistics using quantiles.
    
Kolmogorov-Smirnov statistics using quantiles.
Kolmogorov - Smirnov statistics using quantiles .
def KS_statistics(quantiles, alpha=0.05, alpha_s=0.05):
    samples = quantiles.shape[0]
    assert samples > 1
    q_order = np.append(np.array([0]), np.sort(quantiles))
    ks_y = np.arange(samples+1)/samples - q_order
    T_KS = np.abs(ks_y).max()
    z = q_to_Z(quantiles)
    T_DS = np.log((z**2).mean()) + 1/samples + 1/3/samples**2
    T_DS_ = T_DS/np.sqrt(2/(samples-1)) 
    sign_KS = np.sqrt(-0.5*np.log(alpha)) / np.sqrt(samples)
    sign_DS = sps.erfinv(1-alpha/2.)*np.sqrt(2) * np.sqrt(2/(samples-1))
    p_DS = 2.*(1-scstats.norm.cdf(T_DS_))
    p_KS = np.exp(-2*samples*T_KS**2)
    return T_DS, T_KS, sign_DS, sign_KS, p_DS, p_KS
def KS_statistics ( quantiles , alpha = 0.05 , alpha_s = 0.05 ) : samples = quantiles . shape [ 0 ] assert samples > 1 q_order = np . append ( np . array ( [ 0 ] ) , np . sort ( quantiles ) ) ks_y = np . arange ( samples + 1 ) / samples - q_order T_KS = np . abs ( ks_y ) . max ( ) z = q_to_Z ( quantiles ) T_DS = np . log ( ( z ** 2 ) . mean ( ) ) + 1 / samples + 1 / 3 / samples ** 2 T_DS_ = T_DS / np . sqrt ( 2 / ( samples - 1 ) ) sign_KS = np . sqrt ( - 0.5 * np . log ( alpha ) ) / np . sqrt ( samples ) sign_DS = sps . erfinv ( 1 - alpha / 2. ) * np . sqrt ( 2 ) * np . sqrt ( 2 / ( samples - 1 ) ) p_DS = 2. * ( 1 - scstats . norm . cdf ( T_DS_ ) ) p_KS = np . exp ( - 2 * samples * T_KS ** 2 ) return T_DS , T_KS , sign_DS , sign_KS , p_DS , p_KS
Kolmogorov-Smirnov statistics using quantiles.
Kolmogorov - Smirnov statistics using quantiles .
"""
    Kolmogorov-Smirnov statistics using quantiles.
    """ # dispersion scores # unit normal null distribution #ref_sign_DS = sps.erfinv(1-alpha_s/2.)*np.sqrt(2) #T_DS /= ref_sign_DS #sign_DS /= ref_sign_DS
quantiles
alpha
alpha_s