-
Notifications
You must be signed in to change notification settings - Fork 1
/
KRSimulate.py
35 lines (29 loc) · 894 Bytes
/
KRSimulate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from __future__ import print_function
import functions as f
import math
import testers as t
alpha = 0.01
epsilon = 0.1
largeFrac = 1.0/200
alphaFrac = 1.0/3
iterations = 200
rho = 0.5*epsilon*epsilon
alphaList = [0.1, 0.05, 0.01]
nList = [100, 500, 2000, 5000, 10000]
for alpha in alphaList:
output_filename = "outputs/KR_alpha%.4f_epsilon%.2f.txt"%(alpha, epsilon)
target = open(output_filename, 'a+')
print("filename: %s\n"%(output_filename))
print("alpha: %f, epsilon: %f\n"%(alpha, epsilon), file=target)
print("alpha: %f, epsilon: %f\n"%(alpha, epsilon))
m = 100
for n in nList:
q = f.getUniformDist(n)
p = f.getPaninski(n, alpha)
rTester = t.KR_tester(rho)
rTester.set_q(q)
m = f.getMinimumSampleSize(rTester, p, m, iterations, 2.0/3)
print("n: %d, m: %d"%(n, m), file=target)
target.flush()
print("n: %d, m: %d, ratio: %.3f"%(n, m, 1.0*m/n))
target.close()