code: def moment(p, v, order=1):
      
      if order == 1:
          return (v*p).sum()
      elif order == 2:
          return np.sqrt( ((v**2)*p).sum() - (v*p).sum()**2 )
docs: Calculates the moments of the probability distribution p with vector v