def mnc2mc(mnc, wmean = True):
    '''convert non-central to central moments, uses recursive formula
    optionally adjusts first moment to return mean

    '''
    n = len(mnc)
    mean = mnc[0]
    mnc = [1] + list(mnc)    # add zero moment = 1
    mu = [] #np.zeros(n+1)
    for n,m in enumerate(mnc):
        mu.append(0)
        #[comb(n-1,k,exact=1) for k in range(n)]
        for k in range(n+1):
            mu[n] += (-1)**(n-k) * comb(n,k,exact=1) * mnc[k] * mean**(k-n)
    if wmean:
        mu[1] = mean
    return mu[1:]
dataset/ETHPy150Open statsmodels/statsmodels/statsmodels/stats/moment_helpers.py/mnc2mc/swapped operands of `-`