def run_carma_sampler(args): pmodel = args[0] qmodel = args[1] time, y, ysig = args[2] nsamples = 75000 carma_mcmc = cm.CarmaMCMC(time, y, ysig, pmodel, nsamples, q=qmodel, nburnin=25000) carma = carma_mcmc.RunMCMC() # remove C++ wrapper since it is not 'pickleable', as required by multiprocessing.Pool.map() del carma.sampler return carma
def testFull(self): path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../examples/car4_test.dat") xv, yv, dyv = np.loadtxt(path, unpack=True) nSample = 100 nBurnin = 10 nThin = 1 pModel = 3 qModel = 1 carma1 = carmcmc.CarmaMCMC(xv, yv, dyv, 1, nSample, q=0, nburnin=nBurnin, nthin=nThin) post1 = carma1.RunMCMC() carmap = carmcmc.CarmaMCMC(xv, yv, dyv, pModel, nSample, q=0, nburnin=nBurnin, nthin=nThin) postp = carmap.RunMCMC() carmapqo = carmcmc.CarmaMCMC(xv, yv, dyv, pModel, nSample, q=qModel, nburnin=nBurnin, nthin=nThin) postpqo = carmapqo.RunMCMC() carmapqe = carmcmc.CarmaMCMC(xv, yv, dyv, pModel + 1, nSample, q=qModel, nburnin=nBurnin, nthin=nThin) postpqe = carmapqe.RunMCMC() # tests of yamcmcpp samplers.py post1.effective_samples("sigma") postp.effective_samples("ar_roots") postpqo.effective_samples("ma_coefs") postpqe.effective_samples("ar_coefs") post1.plot_trace("sigma") postp.plot_trace("sigma") postpqo.plot_trace("sigma") postpqe.plot_trace("sigma") post1.plot_1dpdf("mu") postp.plot_1dpdf("mu") postpqo.plot_1dpdf("mu") postpqe.plot_1dpdf("mu") post1.plot_1dpdf("psd_centroid") postp.plot_1dpdf("psd_centroid") postpqo.plot_1dpdf("psd_width") postpqe.plot_1dpdf("psd_width") post1.plot_2dpdf("sigma", "var") postp.plot_2dpdf("sigma", "var", pindex1=0, pindex2=0) postpqo.plot_2dpdf("sigma", "var", pindex1=1, pindex2=1) postpqe.plot_2dpdf("sigma", "var", pindex1=2, pindex2=2) post1.plot_2dkde("sigma", "var") postp.plot_2dkde("sigma", "var", pindex1=0, pindex2=0) postpqo.plot_2dkde("sigma", "var", pindex1=1, pindex2=1) postpqe.plot_2dkde("sigma", "var", pindex1=2, pindex2=2) post1.plot_autocorr("psd_centroid") postp.plot_autocorr("psd_centroid") postpqo.plot_autocorr("psd_centroid") postpqe.plot_autocorr("psd_centroid") post1.plot_parameter("psd_centroid") postp.plot_parameter("psd_centroid") postpqo.plot_parameter("psd_centroid") postpqe.plot_parameter("psd_centroid") post1.posterior_summaries("psd_width") postp.posterior_summaries("psd_width") postpqo.posterior_summaries("psd_width") postpqe.posterior_summaries("psd_width") post1.posterior_summaries("sigma") postp.posterior_summaries("sigma") postpqo.posterior_summaries("sigma") postpqe.posterior_summaries("sigma") # tests of carma_pack carma_pack.py post1.plot_power_spectrum(percentile=95.0, doShow=False) postp.plot_power_spectrum(percentile=95.0, doShow=False) postpqo.plot_power_spectrum(percentile=95.0, doShow=False) postpqe.plot_power_spectrum(percentile=95.0, doShow=False) post1.plot_models(nplot=1000, doShow=False) postp.plot_models(nplot=1000, doShow=False) postpqo.plot_models(nplot=1000, doShow=False) postpqe.plot_models(nplot=1000, doShow=False) for bestfit in ["map", "median", "mean"]: post1.assess_fit(nplot=1000, bestfit=bestfit, doShow=False) postp.assess_fit(nplot=1000, bestfit=bestfit, doShow=False) postpqo.assess_fit(nplot=1000, bestfit=bestfit, doShow=False) postpqe.assess_fit(nplot=1000, bestfit=bestfit, doShow=False)
import numpy as np import matplotlib.pyplot as plt infile = sys.argv[1] xv, yv, dyv = np.loadtxt(sys.argv[1], unpack=True) nSample = 100 nBurnin = 10 nThin = 1 pModel = 3 qModel = 1 carma1 = carmcmc.CarmaMCMC(xv, yv, dyv, 1, nSample, q=0, nburnin=nBurnin, nthin=nThin) post1 = carma1.RunMCMC() carmap = carmcmc.CarmaMCMC(xv, yv, dyv, pModel, nSample, q=0, nburnin=nBurnin, nthin=nThin) postp = carmap.RunMCMC()
import sys, os import yamcmcpp import carmcmc import numpy as np import matplotlib.pyplot as plt infile = sys.argv[1] xv, yv, dyv = np.loadtxt(sys.argv[1], unpack=True) nSample = 500 nBurnin = 50 nThin = 1 pModel = 4 qModel = 1 # This seems to fail when pModel is odd and qModel = 1, and works when pModel is even and qModel=1 carma_model = carmcmc.CarmaMCMC(xv, yv, dyv, pModel, nSample, q=qModel, nburnin=nBurnin, nthin=nThin) post = carma_model.RunMCMC()
# Set up a loop over all filters, and several CARMA p-orders (we set q=0 here) posteriors = {} for f in filters: posteriors[f] = {} idx = np.where(data["filter"] == f) tdb = data["TDB"][idx] mag = data["mag"][idx] dmag = data["dmag"][idx] for p in xrange(1, 10): carma = carmcmc.CarmaMCMC(tdb, mag, dmag, p, NSAMPLE, q=0, nburnin=NBURNIN, nthin=NTHIN) post = carma.RunMCMC() posteriors[f][p] = post # Print out the DIC for all models for f in filters: print "Deviance Information Criterion:" for p in xrange(1, 10): print f, p, posteriors[f][p].DIC()[0] # Print out several useful diagnostic figures for f in filters: for p in xrange(1, 10):