Пример #1
0
def plot_alpha_beta(n=32,p=.3):
    dist_rvs_compound = lambda lmb,t: CompoundPoisson.rvs_s(lmb*t,n,p,compound='log')
    dist_rvs_poisson = lambda lmb,t: poisson.rvs(lmb*t)
    alphas1,betas1,alpha_hats1 = run_simulns(fn=dist_rvs_poisson)
    alphas2,betas2,alpha_hats2 = run_simulns(fn=dist_rvs_compound, n_sim=50000)
    plt.plot(alpha_hats1,alphas1,label='UMP poisson on poisson')
    plt.plot(alpha_hats2,alphas2,label='UMP poisson on compound poisson')
    plt.xlabel('Alpha')
    plt.ylabel('Beta')
    plt.legend(facecolor="black", edgecolor="black")
    fig.savefig("C:\\Users\\ropandey\\OneDrive\\MSFTProj\\HypothTestAIR\\alpha_hat_w_alpha.png", \
        facecolor=fig.get_facecolor(), transparent=True)
    plt.close()
Пример #2
0
def plot_tests_on_distributions():
    alphas1,betas1,alpha_hats1 = run_simulns(fn=dist_rvs_poisson)
    alphas2,betas2,alpha_hats2 = run_simulns(fn=dist_rvs_compound, n_sim=50000)
    alphas3,betas3,alpha_hats3 = run_simulns(fn=dist_rvs_interarrivalw, n_sim=5000)
    alphas4,betas4,alpha_hats4 = run_simulns(fn=dist_rvs_interarrivalw, n_sim=5000, scale=25.0)
    alphas5,betas5,alpha_hats5 = run_simulns(fn=dist_rvs_interarrivalw, n_sim=5000, scale=1/10.0)

    plt.plot(alphas1,betas1,label='UMP poisson on poisson')
    plt.plot(alphas2,betas2,label='UMP poisson on compound poisson')
    plt.plot(alphas3,betas3,label='UMP poisson on interarrival weibull')
    plt.plot(alphas4,betas4,label='UMP poisson sc:25.0 on interarrival weibull')
    plt.plot(alphas5,betas5,label='UMP poisson sc:0.1 on interarrival weibull')
    plt.xlabel('Alpha')
    plt.ylabel('Beta')
    plt.legend(facecolor="black", edgecolor="black")
    fig.savefig("C:\\Users\\rohit\\OneDrive\\MSFTProj\\HypothTestAIR\\all_combinations.png", \
        facecolor=fig.get_facecolor(), transparent=True)
    plt.close()
Пример #3
0
def alpha_plots(n=32,p=.3):
    dist_rvs_compound = lambda lmb,t: CompoundPoisson.rvs_s(lmb*t,n,p,compound='log')
    dist_rvs_poisson = lambda lmb,t: poisson.rvs(lmb*t)
    alphas1,betas1,alpha_hats1 = run_simulns(fn=dist_rvs_compound, n_sim=5000, t1=10.0,t2=3.0)
    alphas2,betas2,alpha_hats2 = run_simulns(fn=dist_rvs_compound, n_sim=5000, t1=3.0,t2=10.0)
    alphas3,betas3,alpha_hats3 = run_simulns(fn=dist_rvs_compound, n_sim=5000, t1=10.0,t2=10.0)
    alphas4,betas4,alpha_hats4 = run_simulns(fn=dist_rvs_compound, n_sim=5000, t1=3.0,t2=3.0)
    alphas5,betas5,alpha_hats5 = run_simulns(fn=dist_rvs_compound, n_sim=5000, lmb=5.0, t1=10.0,t2=10.0)

    plt.plot(alpha_hats1,alphas1,label="t1=10; t2=3; lmb=20")
    plt.plot(alpha_hats2,alphas2,label="t1=3; t2=10; lmb=20")s
    plt.plot(alpha_hats3,alphas3,label="t1=10; t2=10; lmb=20")
    plt.plot(alpha_hats4,alphas4,label="t1=3; t2=3; lmb=20")
    plt.plot(alpha_hats5,alphas5,label="t1=10; t2=10; lmb=5")

    plt.xlabel('Alpha you set')
    plt.ylabel('Alpha you get')
    plt.legend(facecolor="black", edgecolor="black")
    fig.savefig("C:\\Users\\rohit\\OneDrive\\MSFTProj\\HypothTestAIR\\alpha_mapping_no_change.png", \
                    facecolor=fig.get_facecolor(), transparent=True)
    plt.close()
Пример #4
0
def plot_hypotheses_on_distributions():
    alphas1,betas1,alpha_hats1 = run_simulns(fn=dist_rvs_poisson)
    alphas2,betas2,alpha_hats2 = run_simulns(fn=dist_rvs_poisson,scale=2.0)
    alphas3,betas3,alpha_hats3 = run_simulns(fn=dist_rvs_poisson,scale=0.5)
    alphas4,betas4,alpha_hats4 = run_simulns(fn=dist_rvs_compound, n_sim=5000)
    alphas5,betas5,alpha_hats5 = run_simulns(fn=dist_rvs_compound, n_sim=5000,scale=0.3)
    alphas6,betas6,alpha_hats6 = run_simulns(fn=dist_rvs_compound, n_sim=5000,scale=22.4)

    plt.plot(alpha_hats1,alphas1,label="sc=1.0 on Poisson")
    #plt.plot(alpha_hats2,alphas2,label="sc=2.0")
    #plt.plot(alpha_hats3,alphas3,label="sc=0.5")
    plt.plot(alpha_hats4,alphas4,label="sc=1.0 on Compound Poisson")
    #plt.plot(alpha_hats5,alphas5,label="sc=0.3 on CPP")
    plt.plot(alpha_hats6,alphas6,label="sc=22.4 on Compound Poisson")
    plt.legend()
    plt.show()
    plt.plot(alphas1,betas1,label='UMP poisson on poisson')
    plt.plot(alphas2,betas2,label='UMP poisson; sc:2 on poisson')
    plt.plot(alphas3,betas3,label='UMP poisson; sc:0.5 on poisson')
    plt.plot(alphas4,betas4,label='UMP poisson on compound poisson')
    plt.plot(alphas5,betas5,label='UMP poisson sc:0.3 on compund poisson')
    plt.plot(alphas6,betas6,label='UMP poisson sc:22.4 on compund poisson')
    plt.show()
    ## Theoretical alpha-beta profile.
    alpha_hats = np.arange(0,1,0.0001)
    a = binom.isf(alpha_hats,50,0.5)
    betas = binom.cdf(a,50,0.65)
    plt.plot(betas,alpha_hats)
    plt.show()
Пример #5
0
def binom_comp_poisson_alpha_beta():
    dist_rvs_poisson = lambda lmb, t: poisson.rvs(lmb * t)
    alphas1, betas1, alpha_hats1 = run_simulns(fn=dist_rvs_poisson)
    print("Poisson done!")
    dist_rvs_compound = lambda lmb, t: CompoundPoisson.rvs_s(
        lmb * t, 2, .4, compound='binom')
    alphas2, betas2, alpha_hats2 = run_simulns(fn=dist_rvs_compound,
                                               n_sim=50000)
    print("l=2 done")
    dist_rvs_compound = lambda lmb, t: CompoundPoisson.rvs_s(
        lmb * t, 3, .4, compound='binom')
    alphas3, betas3, alpha_hats3 = run_simulns(fn=dist_rvs_compound,
                                               n_sim=5000)
    print("l=3 done")
    dist_rvs_compound = lambda lmb, t: CompoundPoisson.rvs_s(
        lmb * t, 4, .4, compound='binom')
    alphas4, betas4, alpha_hats4 = run_simulns(fn=dist_rvs_compound,
                                               n_sim=5000)
    print("l=4 done")
    dist_rvs_compound = lambda lmb, t: CompoundPoisson.rvs_s(
        lmb * t, 5, .4, compound='binom')
    alphas5, betas5, alpha_hats5 = run_simulns(fn=dist_rvs_compound,
                                               n_sim=5000)
    print("l=5 done")
    dist_rvs_compound = lambda lmb, t: CompoundPoisson.rvs_s(
        lmb * t, 6, .4, compound='binom')
    alphas6, betas6, alpha_hats6 = run_simulns(fn=dist_rvs_compound,
                                               n_sim=5000)
    print("l=5 done")
    dist_rvs_compound = lambda lmb, t: CompoundPoisson.rvs_s(
        lmb * t, 10, .4, compound='binom')
    alphas10, betas10, alpha_hats10 = run_simulns(fn=dist_rvs_compound,
                                                  n_sim=5000)
    print("l=10 done")
    dist_rvs_compound = lambda lmb, t: CompoundPoisson.rvs_s(
        lmb * t, 20, .4, compound='binom')
    alphas20, betas20, alpha_hats20 = run_simulns(fn=dist_rvs_compound,
                                                  n_sim=5000)
    print("all done")

    color_list = sns.color_palette("RdBu_r", 20)
    color_list = color_list.as_hex()

    plt.plot(alphas1, betas1, label='UMP poisson on poisson', color='black')
    plt.plot(alphas2,
             betas2,
             label='UMP poisson on compound poisson l=2',
             color=color_list[1])
    plt.plot(alphas3,
             betas3,
             label='UMP poisson on compound poisson l=3',
             color=color_list[2])
    plt.plot(alphas4,
             betas4,
             label='UMP poisson on compound poisson l=4',
             color=color_list[3])
    plt.plot(alphas5,
             betas5,
             label='UMP poisson on compound poisson l=5',
             color=color_list[4])
    plt.plot(alphas6,
             betas6,
             label='UMP poisson on compound poisson l=6',
             color=color_list[5])
    plt.plot(alphas10,
             betas10,
             label='UMP poisson on compound poisson l=10',
             color=color_list[9])
    plt.plot(alphas20,
             betas20,
             label='UMP poisson on compound poisson l=20',
             color=color_list[19])
    plt.xlabel('Alpha')
    plt.ylabel('Beta')
    plt.legend()
    plt.show()

    plt.plot(alpha_hats1, alphas1, label='UMP poisson on poisson')
    plt.plot(alpha_hats2,
             alphas2,
             label='UMP poisson on compound poisson l=2',
             color=color_list[1])
    plt.plot(alpha_hats3,
             alphas3,
             label='UMP poisson on compound poisson l=3',
             color=color_list[2])
    plt.plot(alpha_hats4,
             alphas4,
             label='UMP poisson on compound poisson l=4',
             color=color_list[3])
    plt.plot(alpha_hats5,
             alphas5,
             label='UMP poisson on compound poisson l=5',
             color=color_list[4])
    plt.plot(alpha_hats6,
             alphas6,
             label='UMP poisson on compound poisson l=6',
             color=color_list[5])
    plt.plot(alpha_hats10,
             alphas10,
             label='UMP poisson on compound poisson l=10',
             color=color_list[9])
    plt.plot(alpha_hats20,
             alphas20,
             label='UMP poisson on compound poisson l=20',
             color=color_list[19])
    plt.xlabel('Type-1 error')
    plt.ylabel('False positive rate')
    plt.legend()
    plt.show()