Advertisement
overwater

Untitled

May 21st, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. def test_chi(seq):
  2.     K = 1000
  3.     n = len(seq)
  4.     p = np.array([1.0 / K for i in range(K)])
  5.     v = np.zeros(K)
  6.     for el in seq:
  7.         v[int(el * K)] += 1
  8.     chi2 = np.sum([(v[k] - n * p[k]) ** 2 / (n * p[k]) for k in range(K)])
  9.     thres = stats.chi2.ppf(1-eps_0, K - 1)
  10.     if chi2 < thres:
  11.         ans = Fore.GREEN + 'H0' + Fore.BLACK
  12.     else:
  13.         ans = Fore.RED + 'H1' + Fore.BLACK
  14.     return chi2, thres, ans
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement