#NEWLINE# def cumulant_from_moments( momt , n ) : #NEWLINE# #INDENT# 'Compute n-th cumulant given moments.\n\n    Parameters\n    ----------\n    momt: array_like\n        `momt[j]` contains `(j+1)`-th moment.\n        These can be raw moments around zero, or central moments\n        (in which case, `momt[0]` == 0).\n    n: integer\n        which cumulant to calculate (must be >1)\n\n    Returns\n    -------\n    kappa: float\n        n-th cumulant.\n\n    ' #NEWLINE# if ( n < 1 ) : #NEWLINE# #INDENT# raise ValueError ( ( 'Expected a positive integer. Got %s instead.' % n ) ) #NEWLINE# #UNINDENT# if ( len ( momt ) < n ) : #NEWLINE# #INDENT# raise ValueError ( ( '%s-th cumulant requires %s moments, only got %s.' % ( n , r , len ( momt ) ) ) ) #NEWLINE# #UNINDENT# kappa = 0.0 #NEWLINE# for p in _faa_di_bruno_partitions ( n ) : #NEWLINE# #INDENT# r = sum ( ( k for ( m , k ) in p ) ) #NEWLINE# term = ( ( ( - 1 ) ** ( r - 1 ) ) * factorial ( ( r - 1 ) ) ) #NEWLINE# for ( m , k ) in p : #NEWLINE# #INDENT# term *= ( np . power ( ( momt [ ( m - 1 ) ] / factorial ( m ) ) , k ) / factorial ( k ) ) #NEWLINE# #UNINDENT# kappa += term #NEWLINE# #UNINDENT# kappa *= factorial ( n ) #NEWLINE# return kappa