Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- import math
- T = 100
- thresholds = []
- probabilities = np.linspace(0,1,100)
- for p in probabilities:
- for k in range(0, T+1):
- sum = 0
- for i in range(0, k + 1):
- sum += (math.factorial(T) / (math.factorial(i) * math.factorial(T - i))) * p ** (i) * (1 - p) ** (T - i)
- if sum >= 0.01:
- thresholds.append(k)
- break
- plt.plot(probabilities,thresholds, label='T = ' + str(T))
- plt.legend()
- plt.ylabel('Threshold')
- plt.xlabel('Probability')
- plt.show()
- p = 0.5
- thresholds = []
- read_count = np.linspace(0, 500, 100)
- for T in read_count:
- for k in range(0, int(T+1)):
- sum = 0
- for i in range(0, k + 1):
- sum += (math.factorial(int(T)) / (math.factorial(i) * math.factorial(int(T) - i))) * p ** (i) * (1 - p) ** (int(T) - i)
- if sum >= 0.01:
- thresholds.append(k)
- break
- plt.plot(read_count,thresholds, label='p = ' + str(p))
- plt.legend()
- plt.ylabel('Threshold')
- plt.xlabel('T (reading count)')
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement