def gauss_2d(nsamples=1000): """ Another simple test plot 1d gaussian sampled from each sampler visualized as a joint 2d gaussian """ gaussian = misc.distributions.TestGaussian(ndims=1) control = Control(gaussian.Xinit, gaussian.E, gaussian.dEdX) experimental = ContinuousTimeHMC(gaussian.Xinit, gaussian.E, gaussian.dEdX) with sns.axes_style("white"): sns.jointplot(control.sample(nsamples)[0], experimental.sample(nsamples)[0], kind="hex", stat_func=None)
def hist_1d(distr, nsamples=1000, nbins=250): """ plots a 1d histogram from each sampler distr is (an unitialized) class from distributions """ distribution = distr(ndims=1) control = Control(distribution.Xinit, distribution.E, distribution.dEdX) experimental = ContinuousTimeHMC(distribution.Xinit, distribution.E, distribution.dEdX) plt.hist(control.sample(nsamples)[0], nbins, normed=True, label="Standard Control", alpha=0.5) plt.hist(experimental.sample(nsamples)[0], nbins, normed=True, label="Continuous-time Control", alpha=0.5) plt.legend()