Three Chains
============

Plot three chains together. Name the chains to get a legend.


"""
import numpy as np
from numpy.random import normal, random, multivariate_normal
from chainconsumer import ChainConsumer


if __name__ == "__main__":
    np.random.seed(0)
    cov = random(size=(3, 3)) + np.identity(3)
    data = multivariate_normal(normal(size=3), np.dot(cov, cov.T), size=100000)
    cov = random(size=(3, 3)) + np.identity(3)
    data2 = multivariate_normal(normal(size=3), np.dot(cov, cov.T), size=100000)
    cov = random(size=(3, 3)) + np.identity(3)
    data3 = multivariate_normal(normal(size=3), np.dot(cov, cov.T), size=100000)

    # If the parameters are the same between chains, you can just pass it the
    # first time, and they will become the default parameters.
    fig = ChainConsumer()\
        .add_chain(data, parameters=["$x$", "$y$", r"$\epsilon$"], name="Test chain")\
        .add_chain(data2, name="Chain2")\
        .add_chain(data3, name="Chain3") \
        .plotter.plot()

    fig.set_size_inches(4.5 + fig.get_size_inches())  # Resize fig for doco. You don't need this.
Beispiel #2
0
"""
=========
One Chain
=========

Plot one chain with parameter names.

Because we are only plotting one chain, we will get
parameter bounds on the marginalised surfaces by
default.
"""

import numpy as np
from numpy.random import normal, multivariate_normal
from chainconsumer import ChainConsumer


np.random.seed(0)
cov = 1e2 * normal(size=(3, 3))
data = multivariate_normal(1e3 * normal(size=3), np.dot(cov, cov.T), size=100000)

# If you pass in parameter labels and only one chain, you can also get parameter bounds
fig = ChainConsumer().add_chain(data, parameters=["$x$", "$y$", r"$\epsilon$"]).plotter.plot()

fig.set_size_inches(4.5 + fig.get_size_inches())  # Resize fig for doco. You don't need this.
Beispiel #3
0
Mh = 1.087 * NoH  #====================Mh = 1.087*1.e8*NoH

logL = np.loadtxt(path + "Powerspectrum_THANN_prob.out",
                  usecols=(0),
                  unpack=True)  #=== loglikelyhood =====#

#df = pd.DataFrame({'$\zeta$':n_ion,'$Rmfp$':R_mfp,'$Mhalo_{min}(10^8$ $M_\odot)$':NoH})

data = [n_ion, R_mfp, NoH]

fig = ChainConsumer().add_chain(
    data, parameters=["$\zeta$", "$R_{mfp}$", "$Mh_{min}$"]).plotter.plot()

fig.set_size_inches(
    3 + fig.get_size_inches())  # Resize fig for doco. You don't need
fig.savefig('plot_nion_{0:.3f}_R_mfp_{1:.3f}_Mhalo_{2:.3f}.png'.format(
    n_ion.mean(), R_mfp.mean(), Mh.mean()),
            dpi=400)
print('plot_nion_{0:.3f}_R_mfp_{1:.3f}_Mhalo_{2:.3f}.png'.format(
    n_ion.mean(), R_mfp.mean(), Mh.mean()))
'''
plt.subplot(312)
plt.ylabel('freq.')
plt.xlabel('$R_{mfp}$')
plt.hist(R_mfp,bins=100,color='orange')
plt.axvline(R_mfp.mean(),color='green',lw=2)
plt.subplot(313)
plt.xlabel('$Mh_{min}$')
plt.ylabel('$freq$')