MCMC Sampler

The MCMC sampling is done using emcee based CosmoHammer.

For more details about

emcee: https://emcee.readthedocs.io/en/stable/

CosmoHammer: http://cosmo-docs.phys.ethz.ch/cosmoHammer/

[1]:
import emcee
import cosmoHammer
import numpy as np

we have used an older version of emcee.

[2]:
emcee.__version__,cosmoHammer.__version__
[2]:
(u'2.2.1', '0.6.1')

All the custom core and likelihood modules are already in the EmuPBk’s MCMC class.

[3]:
from EmuPBk.MCMC import sampler

Loading the data

[4]:
path = '/home/ht/PycharmProjects/EmuPBK/vv/data/data_Powerspectrum/'
data = np.loadtxt(path+'pk_test')
nbins = np.loadtxt(path+'nbins_test')
[5]:
mcmc = sampler.Run_MCMC(data[0],nbins[0])
'''
:param data: load your data
:param cov: data for covariance calculation
'''

[5]:
'\n:param data: load your data\n:param cov: data for covariance calculation\n'

MCMC using already existing ANN models

[7]:
mcmc.load_existing_model(name = 'Pk')

 '''
        Use the existing ANN models for MCMC analysis
        :param name: use ('Pk','Bk02','Bk03','Bk15')==>for powerspectrum, Bispectrum02, Bispectrum03, Bispectrum15
'''
Core setup is done
Core setup is done
logLikelihood setup is done
[9]:
mcmc.sampler(walker_ratio=6, burnin=200, samples=200, threads=-1)
find best fit point
converged after 131 iterations!
best fit found:  [[-1.32994776e-05]] [ 16.01032703  31.67938218 526.2873946 ]
start sampling:.
The time taken 29.50 sec. done!
Done!

MCMC using Your own model

[ ]:
mcmc.load_model(load_model,name,rescale)

'''
        :param load_model: load your own model, (give the path)
        :param name: name of data, ('Pk','Bk02','Bk03','Bk15')==>for powerspectrum, Bispectrum02, Bispectrum03, Bispectrum15
        :param rescale: rescale used in the training
'''

mcmc.sampler(walker_ratio=6, burnin=200, samples=200, threads=-1)