neuroprob/utils/stats.py
def count_KS_method(count_dist, mean_func, sample_bin, spike_binned, rate, shape=None, 
                    deq_noise=None):
    """
    Overdispersion analysis using rate-rescaled distributions and Kolmogorov-Smirnov 
    statistics. Trajectory lengths are given, unless the expected count is below 
    min_spikes (avoid dequantization effect)
    
    :param LambdaType count_dist: lambda function with input (count, rate, time) and output p
    :param LambdaType mean_func: lambda function with input (avg_rate*T) and output avg_cnt
    :param float sample_bin: length of time bin
    :param numpy.array spike_ind: indices of the spike times
    :param numpy.array rate: rate as sampled at sample_bin
    :param float alpha: significance level of the statistical test
    :returns: quantiles, q_order, ks_y, T_DS, T_KS, sign_DS, sign_KS
    :rtype: tuple
    """
    if shape is not None:
        assert rate.shape[0] == shape.shape[0]
    traj_lens = rate.shape[0]
    q_cdf = []
    
    if deq_noise is None:
        deq_noise = np.random.uniform(size=spike_binned.shape)
        
    for tt in range(traj_lens):
        f_p = lambda c: count_dist(c, rate[tt], shape[tt] if shape is not None else None,
                                   sample_bin)
        q_cdf.append(cdf_count_deq(int(spike_binned[tt]), deq_noise[tt], f_p))

    quantiles = np.array(q_cdf).flatten()
    return quantiles

    Overdispersion analysis using rate-rescaled distributions and Kolmogorov-Smirnov 
    statistics. Trajectory lengths are given, unless the expected count is below 
    min_spikes (avoid dequantization effect)
    
    :param LambdaType count_dist: lambda function with input (count, rate, time) and output p
    :param LambdaType mean_func: lambda function with input (avg_rate*T) and output avg_cnt
    :param float sample_bin: length of time bin
    :param numpy.array spike_ind: indices of the spike times
    :param numpy.array rate: rate as sampled at sample_bin
    :param float alpha: significance level of the statistical test
    :returns: quantiles, q_order, ks_y, T_DS, T_KS, sign_DS, sign_KS
    :rtype: tuple
    
Overdispersion analysis using rate-rescaled distributions and Kolmogorov-Smirnov
statistics. Trajectory lengths are given, unless the expected count is below
min_spikes (avoid dequantization effect)
Overdispersion analysis using rate - rescaled distributions and Kolmogorov - Smirnov statistics . Trajectory lengths are given unless the expected count is below min_spikes ( avoid dequantization effect )
def count_KS_method(count_dist, mean_func, sample_bin, spike_binned, rate, shape=None, 
                    deq_noise=None):
    if shape is not None:
        assert rate.shape[0] == shape.shape[0]
    traj_lens = rate.shape[0]
    q_cdf = []
    if deq_noise is None:
        deq_noise = np.random.uniform(size=spike_binned.shape)
    for tt in range(traj_lens):
        f_p = lambda c: count_dist(c, rate[tt], shape[tt] if shape is not None else None,
                                   sample_bin)
        q_cdf.append(cdf_count_deq(int(spike_binned[tt]), deq_noise[tt], f_p))
    quantiles = np.array(q_cdf).flatten()
    return quantiles
def count_KS_method ( count_dist , mean_func , sample_bin , spike_binned , rate , shape = None , deq_noise = None ) : if shape is not None : assert rate . shape [ 0 ] == shape . shape [ 0 ] traj_lens = rate . shape [ 0 ] q_cdf = [ ] if deq_noise is None : deq_noise = np . random . uniform ( size = spike_binned . shape ) for tt in range ( traj_lens ) : f_p = lambda c : count_dist ( c , rate [ tt ] , shape [ tt ] if shape is not None else None , sample_bin ) q_cdf . append ( cdf_count_deq ( int ( spike_binned [ tt ] ) , deq_noise [ tt ] , f_p ) ) quantiles = np . array ( q_cdf ) . flatten ( ) return quantiles
Overdispersion analysis using rate-rescaled distributions and Kolmogorov-Smirnov
statistics.
Overdispersion analysis using rate - rescaled distributions and Kolmogorov - Smirnov statistics .
"""
    Overdispersion analysis using rate-rescaled distributions and Kolmogorov-Smirnov 
    statistics. Trajectory lengths are given, unless the expected count is below 
    min_spikes (avoid dequantization effect)
    
    :param LambdaType count_dist: lambda function with input (count, rate, time) and output p
    :param LambdaType mean_func: lambda function with input (avg_rate*T) and output avg_cnt
    :param float sample_bin: length of time bin
    :param numpy.array spike_ind: indices of the spike times
    :param numpy.array rate: rate as sampled at sample_bin
    :param float alpha: significance level of the statistical test
    :returns: quantiles, q_order, ks_y, T_DS, T_KS, sign_DS, sign_KS
    :rtype: tuple
    """
quantiles, q_order, ks_y, T_DS, T_KS, sign_DS, sign_KS
quantiles q_order ks_y T_DS T_KS sign_DS sign_KS
tuple
count_dist
lambda function with input (count, rate, time) and output p
lambda function with input ( count rate time ) and output p
mean_func
lambda function with input (avg_rate*T) and output avg_cnt
lambda function with input ( avg_rate * T ) and output avg_cnt
sample_bin
length of time bin
length of time bin
spike_binned
rate
rate as sampled at sample_bin
rate as sampled at sample_bin
shape
deq_noise
spike_ind
indices of the spike times
indices of the spike times
alpha
significance level of the statistical test
significance level of the statistical test