neuroprob/utils/stats.py
def cmp_count_prob(n, rate, nu, sim_time, J=100):
    """
    Conway-Maxwell-Poisson count distribution. The partition function is evaluated using logsumexp 
    inspired methodology to avoid floating point overflows.
    """
    g = rate*sim_time
    if g == 0:
        return (n == 0).astype(float)
    
    j = np.arange(J+1)
    lnum = np.log(g)*j
    lden = np.log(sps.factorial(j))*nu
    dl = lnum-lden
    dl_m = dl.max()
    logsumexp_Z = np.log(np.exp(dl-dl_m).sum()) + dl_m # numerically stable
    return np.exp(np.log(g)*n - logsumexp_Z - sps.gammaln(n+1)*nu)

    Conway-Maxwell-Poisson count distribution. The partition function is evaluated using logsumexp 
    inspired methodology to avoid floating point overflows.
    
Conway-Maxwell-Poisson count distribution. The partition function is evaluated using logsumexp
inspired methodology to avoid floating point overflows.
Conway - Maxwell - Poisson count distribution . The partition function is evaluated using logsumexp inspired methodology to avoid floating point overflows .
def cmp_count_prob(n, rate, nu, sim_time, J=100):
    g = rate*sim_time
    if g == 0:
        return (n == 0).astype(float)
    j = np.arange(J+1)
    lnum = np.log(g)*j
    lden = np.log(sps.factorial(j))*nu
    dl = lnum-lden
    dl_m = dl.max()
    logsumexp_Z = np.log(np.exp(dl-dl_m).sum()) + dl_m 
    return np.exp(np.log(g)*n - logsumexp_Z - sps.gammaln(n+1)*nu)
def cmp_count_prob ( n , rate , nu , sim_time , J = 100 ) : g = rate * sim_time if g == 0 : return ( n == 0 ) . astype ( float ) j = np . arange ( J + 1 ) lnum = np . log ( g ) * j lden = np . log ( sps . factorial ( j ) ) * nu dl = lnum - lden dl_m = dl . max ( ) logsumexp_Z = np . log ( np . exp ( dl - dl_m ) . sum ( ) ) + dl_m return np . exp ( np . log ( g ) * n - logsumexp_Z - sps . gammaln ( n + 1 ) * nu )
Conway-Maxwell-Poisson count distribution.
Conway - Maxwell - Poisson count distribution .
"""
    Conway-Maxwell-Poisson count distribution. The partition function is evaluated using logsumexp 
    inspired methodology to avoid floating point overflows.
    """ # numerically stable
n
rate
nu
sim_time
J