Exemplo n.º 1
0
def gauss_2d(nsamples=1000):
    """
    Another simple test plot
    1d gaussian sampled from each sampler visualized as a joint 2d gaussian
    """
    gaussian = TestGaussian(ndims=1)
    control = HMCBase(distribution=gaussian)
    experimental = MarkovJumpHMC(distribution=gaussian, resample=False)

    with sns.axes_style("white"):
        sns.jointplot(control.sample(nsamples)[0],
                      experimental.sample(nsamples)[0],
                      kind='hex',
                      stat_func=None)
Exemplo n.º 2
0
def hist_1d(distr, nsamples=1000, nbins=250, control=True, resample=True):
    """
    plots a 1d histogram from each sampler
    distr is (an unitialized) class from distributions
    """
    distribution = distr(ndims=1)
    control_smp = HMCBase(distribution=distribution, epsilon=1)
    experimental_smp = MarkovJumpHMC(distribution=distribution, resample=resample, epsilon=1)

    if control:
        plt.hist(control_smp.sample(nsamples)[0], nbins, normed=True, label="Standard HMCBase", alpha=.5)

    plt.hist(experimental_smp.sample(nsamples)[0], nbins, normed=True, label="Continuous-time HMCBase",alpha=.5)
    plt.legend()
Exemplo n.º 3
0
def gauss_2d(nsamples=1000):
    """
    Another simple test plot
    1d gaussian sampled from each sampler visualized as a joint 2d gaussian
    """
    gaussian = TestGaussian(ndims=1)
    control = HMCBase(distribution=gaussian)
    experimental = MarkovJumpHMC(distribution=gaussian, resample=False)


    with sns.axes_style("white"):
        sns.jointplot(
            control.sample(nsamples)[0],
            experimental.sample(nsamples)[0],
            kind='hex',
            stat_func=None)
Exemplo n.º 4
0
def hist_1d(distr, nsamples=1000, nbins=250, control=True, resample=True):
    """
    plots a 1d histogram from each sampler
    distr is (an unitialized) class from distributions
    """
    distribution = distr(ndims=1)
    control_smp = HMCBase(distribution=distribution, epsilon=1)
    experimental_smp = MarkovJumpHMC(distribution=distribution,
                                     resample=resample,
                                     epsilon=1)

    if control:
        plt.hist(control_smp.sample(nsamples)[0],
                 nbins,
                 normed=True,
                 label="Standard HMCBase",
                 alpha=.5)

    plt.hist(experimental_smp.sample(nsamples)[0],
             nbins,
             normed=True,
             label="Continuous-time HMCBase",
             alpha=.5)
    plt.legend()