SHARE
TWEET

Untitled

a guest Dec 14th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. import math
  4.  
  5. T = 100
  6. thresholds = []
  7. probabilities = np.linspace(0,1,100)
  8.  
  9. for p in probabilities:
  10.     for k in range(0, T+1):
  11.         sum = 0
  12.         for i in range(0, k + 1):
  13.             sum += (math.factorial(T) / (math.factorial(i) * math.factorial(T - i))) * p ** (i) * (1 - p) ** (T - i)
  14.         if sum >= 0.01:
  15.             thresholds.append(k)
  16.             break
  17.  
  18. plt.plot(probabilities,thresholds, label='T = ' + str(T))
  19. plt.legend()
  20. plt.ylabel('Threshold')
  21. plt.xlabel('Probability')
  22. plt.show()
  23.  
  24. p = 0.5
  25. thresholds = []
  26. read_count  = np.linspace(0, 500, 100)
  27. for T in read_count:
  28.     for k in range(0, int(T+1)):
  29.         sum = 0
  30.         for i in range(0, k + 1):
  31.             sum += (math.factorial(int(T)) / (math.factorial(i) * math.factorial(int(T) - i))) * p ** (i) * (1 - p) ** (int(T) - i)
  32.         if sum >= 0.01:
  33.             thresholds.append(k)
  34.             break
  35.  
  36. plt.plot(read_count,thresholds, label='p = ' + str(p))
  37. plt.legend()
  38. plt.ylabel('Threshold')
  39. plt.xlabel('T (reading count)')
  40. plt.show()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top