def moment(a, moment=1, axis=0, nan_policy='propagate'):
 (a, axis) = _chk_asarray(a, axis)
 (contains_nan, nan_policy) = _contains_nan(a, nan_policy)
 if (contains_nan and (nan_policy == 'omit')):
  a = ma.masked_invalid(a)
  return mstats_basic.moment(a, moment, axis)
 if (a.size == 0):
  if np.isscalar(moment):
   return np.nan
  else:
   return (np.ones(np.asarray(moment).shape, dtype=np.float64) * np.nan)
 if (not np.isscalar(moment)):
  mmnt = [_moment(a, i, axis) for i in moment]
  return np.array(mmnt)
 else:
  return _moment(a, moment, axis)

def moment ( a , moment = 1 , axis = 0 , nan_policy = 'propagate' ) : ( a , axis ) = _chk_asarray ( a , axis ) ( contains_nan , nan_policy ) = _contains_nan ( a , nan_policy ) if ( contains_nan and ( nan_policy == 'omit' ) ) : a = ma . masked_invalid ( a ) return mstats_basic . moment ( a , moment , axis ) if ( a . size == 0 ) : if np . isscalar ( moment ) : return np . nan else : return ( np . ones ( np . asarray ( moment ) . shape , dtype = np . float64 ) * np . nan ) if ( not np . isscalar ( moment ) ) : mmnt = [ _moment ( a , i , axis ) for i in moment ] return np . array ( mmnt ) else : return _moment ( a , moment , axis )
calculates the nth moment about the mean for a sample .