Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
rejection sampling used in accuracy vs sample size test
  • Loading branch information
kbudhath committed Sep 25, 2017
1 parent 46b9efe commit dccbe53
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions test_synthetic.py
Expand Up @@ -561,9 +561,9 @@ def test_hypercompression():


def test_sample_size():
nsim = 500
nsim = 1000
level = 0.05
sizes = [100, 500, 1000, 2500, 5000]
sizes = [100, 400, 700, 1000, 1300, 1600, 2000]
suppfX = range(-7, 8)
srcX = "geometric"

Expand All @@ -575,14 +575,28 @@ def test_sample_size():
sys.stdout.flush()
# progress(0, len(sizes))
for k, size in enumerate(sizes):
nsamples = 0
nc_dc, nc_dr, nc_cisc, nc_crispe, nc_crisp = 0, 0, 0, 0, 0
for j in xrange(nsim):
while nsamples < nsim:
X = generate_X(srcX, size)
suppX = list(set(X))
f = map_randomly(suppX, suppfX)
N = generate_additive_N(size)
Y = [f[X[i]] + N[i] for i in xrange(size)]

# check if f(x) + supp N are disjoint for x in domx
suppN = set(N)
decomps = []
for x in suppX:
fx = f[x]
sum_fx_suppN = set([fx + n for n in suppN])
decomps.append(sum_fx_suppN)

non_overlapping_noise = are_disjoint(decomps)
if non_overlapping_noise:
continue

nsamples += 1
dc_score = dc(dc_compat(X), dc_compat(Y))
dr_score = dr(X, Y, level)
cisc_score = cisc(X, Y)
Expand All @@ -609,4 +623,5 @@ def test_sample_size():


if __name__ == "__main__":
test_accuracy()
test_sample_size()
# test_accuracy()

0 comments on commit dccbe53

Please sign in to comment.