from math import sqrt


def meanstdv(members):
  """
  Calculate mean and standard deviation of data x[]:
      mean = {\sum_i x_i \over n}
      std = sqrt(\sum_i (x_i - mean)^2 \over n-1)
  """
  num, mean, std = len(members), 0, 0
  for item in members:
    mean = mean + item
  mean = mean / float(num)
  for item in members:
    std = std + (item - mean)**2
  std = sqrt(std / float(num - 1))
  return mean, std