Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
rejection sampling to ensure identifiability
  • Loading branch information
kbudhath committed Oct 16, 2017
1 parent 83c6221 commit ce9411c
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions test_synthetic.py
Expand Up @@ -203,7 +203,7 @@ def test_accuracy():
size = 1000
level = 0.01
suppfX = range(-7, 8)
srcsX = ["uniform", "binomial", "negativeBinomial",
srcsX = ["negativeBinomial", "uniform", "binomial", "negativeBinomial",
"geometric", "hypergeometric", "poisson", "multinomial"]
print "-" * 70
print "%18s%10s%10s%10s%10s%10s" % ("TYPE_X", "DC", "DR", "CISC", "CRISPE", "CRISP")
Expand Down Expand Up @@ -489,20 +489,35 @@ def test_significance():

def test_hypercompression():
m = 100
size = 100
size = 500
alpha = 0.01
suppfX = range(-7, 8)
srcX = "geometric"

fp = open("results/no-hypercompression.dat", "w")
diffs = []
decisions = [] # 1=correct, -1=incorrect, 0=wrong
for i in xrange(m):
nsamples = 0
while nsamples < m:
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
crisp_score = crisp(X, Y)
diff = abs(crisp_score[0] - crisp_score[1])

Expand Down Expand Up @@ -562,7 +577,7 @@ def test_hypercompression():
def test_sample_size():
nsim = 1000
level = 0.05
sizes = [100, 400, 700, 1000, 1300, 1600, 2000]
sizes = [200, 100, 400, 700, 1000, 1300, 1600, 2000]
suppfX = range(-7, 8)
srcX = "geometric"

Expand Down Expand Up @@ -621,8 +636,9 @@ def test_sample_size():
fp.close()


def test_accuracy_pvalue():
def test_accuracy_alpha():
print "testing various critical thresholds for DR"
sys.stdout.flus()
nsim = 1000
size = 1000
level = 0.01
Expand Down Expand Up @@ -658,9 +674,11 @@ def test_accuracy_pvalue():
assert nsamples == nsim
acc = ncorrect * 100 / nsim
print level, acc
sys.stdout.flus()


if __name__ == "__main__":
# test_sample_size()
test_sample_size()
# test_accuracy()
test_accuracy_pvalue()
# test_accuracy_alpha()
# test_hypercompression()

0 comments on commit ce9411c

Please sign in to comment.