In [ ]:
%load_ext autoreload
%autoreload 2
%matplotlib inline
#%config InlineBackend.figure_format = 'svg'
#%config InlineBackend.figure_format = 'pdf'
import freqopttest.util as util
import freqopttest.data as data
import freqopttest.ex.exglobal as exglo
import freqopttest.kernel as kernel
import freqopttest.tst as tst
import freqopttest.glo as glo
import freqopttest.plot as plot
import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as stats
import sys

In [ ]:
def load_plot_vs_J(fname, h1_true, show_legend=True):
    ex = 3
    func_xvalues = lambda results: results['list_J']
    def func_title(results):
        repeats, _, n_methods = results['test_results'].shape
        alpha = results['alpha']
        test_size = (1.0 - results['tr_proportion'])*results['sample_size']
        title = '%s. %d trials. test size: %d. $\\alpha$ = %.2g.'%\
            ( results['prob_label'], repeats, test_size, alpha)
        return title
   
    results = plot.plot_prob_stat_above_thresh(
        ex, fname, h1_true, func_xvalues, 'J', func_title)
    plt.title('')
    plt.legend().set_visible(show_legend)
    return results

In [ ]:
# font options
font = {
    #'family' : 'normal',
    #'weight' : 'bold',
    'size'   : 18
}

plt.rc('font', **font)
plt.rc('lines', linewidth=2)

In [ ]:
# H0 true. Same Gauss. 
#sg_fname = 'ex3-sg_d50-me4_rs100_jmi5_jma25_a0.010_trp0.50.p'
#sg_fname = 'ex3-sg_d50-me4_rs500_n20000_jmi2_jma6_a0.010_trp0.50.p'
sg_fname = 'ex3-sg_d50-me4_rs100_n10000_jmi2_jma6_a0.010_trp0.50.p'
sg_results = load_plot_vs_J(sg_fname, False, show_legend=False)
plt.savefig(sg_fname.replace('.p', '.pdf', 1))

In [ ]:
# H1 true. Blobs
#blobs_fname = 'ex3-SSBlobs-me4_rs500_n20000_jmi2_jma6_a0.010_trp0.50.p'
blobs_fname = 'ex3-SSBlobs-me4_rs100_n10000_jmi2_jma6_a0.010_trp0.50.p'
blobs_results = load_plot_vs_J(blobs_fname, True, show_legend=False)
plt.savefig(blobs_fname.replace('.p', '.pdf', 1))

In [ ]:
# H1 true. Gaussian mean diff
#gmd_fname = 'ex3-gmd_d100-me4_rs100_jmi5_jma25_a0.010_trp0.50.p'
#gmd_fname = 'ex3-gmd_d100-me4_rs500_n20000_jmi2_jma6_a0.010_trp0.50.p'
gmd_fname = 'ex3-gmd_d100-me4_rs100_n10000_jmi2_jma6_a0.010_trp0.50.p'
gmd_results = load_plot_vs_J(gmd_fname, True, show_legend=True)
plt.ylim([0.2, 1.03])
plt.legend(loc='best')
plt.savefig(gmd_fname.replace('.p', '.pdf', 1))

In [ ]:
# H1 true. Gaussian variance diff
#gvd50_fname = 'ex3-gvd_d50-me4_rs100_jmi5_jma25_a0.010_trp0.50.p'
#gvd50_fname = 'ex3-gvd_d50-me4_rs500_n20000_jmi2_jma6_a0.010_trp0.50.p'
gvd50_fname = 'ex3-gvd_d50-me4_rs100_n10000_jmi2_jma6_a0.010_trp0.50.p'
gvd50_results = load_plot_vs_J(gvd50_fname, True)
plt.savefig(gvd50_fname.replace('.p', '.pdf', 1))

In [ ]:
# gmd d=2 with very large J
gmd2_fname = 'ex3-gmd_d2-me1_rs100_n2000_jmi300_jma500_a0.010_trp0.50.p'
gmd2_results = load_plot_vs_J(gmd2_fname, True, show_legend=True)
#plt.ylim([0.2, 1.03])
plt.legend(loc='best')
plt.grid(True)

In [ ]: