本文整理汇总了Python中chainconsumer.ChainConsumer.divide_chain方法的典型用法代码示例。如果您正苦于以下问题:Python ChainConsumer.divide_chain方法的具体用法?Python ChainConsumer.divide_chain怎么用?Python ChainConsumer.divide_chain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chainconsumer.ChainConsumer
的用法示例。
在下文中一共展示了ChainConsumer.divide_chain方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: range
# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import divide_chain [as 别名]
colours = ["#4CAF50", "#D32F2F", "#1E88E5"] * n
for i in range(n):
mean, std, zeros, calibration, threshold, lall, zall, call, mask, num_obs = get_data()
theta = [mean, std] + zeros.tolist()
kwargs = {"num_steps": 40000, "num_burn": 30000, "save_interval": 60,
"plot_covariance": True} # , "unify_latent": True # , "callback": v.callback
sampler = BatchMetropolisHastings(num_walkers=w, kwargs=kwargs, temp_dir=t % i, num_cores=4)
model_good = EfficiencyModelUncorrected(call, zall, calibration, zeros, name="Good%d" % i)
model_good.fit(sampler, chain_consumer=c) # , include_latent=True
model_un = EfficiencyModelUncorrected(call[mask], zall[mask], calibration,
zeros, name="Uncorrected%d" % i)
model_un.fit(sampler, chain_consumer=c)
model_cor = EfficiencyModelCorrected(call[mask], zall[mask], calibration, zeros,
threshold, num_obs,
dir_name + "/output", name="Corrected%d" % i)
model_cor.fit(sampler, chain_consumer=c)
c.configure_bar(shade=True)
c.configure_general(bins=1.0, colours=colours)
c.configure_contour(sigmas=[0, 0.01, 1, 2], contourf=True, contourf_alpha=0.2)
c.plot(filename=plot_file, truth=theta, figsize=(5, 5), legend=False, parameters=2)
for i in range(len(c.chains)):
c.plot_walks(filename=walk_file % c.names[i], chain=i, truth=theta)
c.divide_chain(i, w).configure_general(rainbow=True) \
.plot(figsize=(5, 5), filename=plot_file.replace(".png", "_%s.png" % c.names[i]),
truth=theta)
示例2: walkers
# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import divide_chain [as 别名]
================
ChainConsumer can split one chain into many!
If you use a sampling algorithm with multiple walkers (which
is fairly common), it can be useful to plot each walker as a separate chain
so that you can verify that your walkers have all converged to the same place.
You can use the `plot_walks` method for this, or the convergence diagnostics,
but the more options the better!
In the below example, I assume the generated data was created using ten walkers.
I introduce some fake shift in the data to badly emulate walker drift.
"""
import numpy as np
from numpy.random import multivariate_normal
from chainconsumer import ChainConsumer
np.random.seed(0)
data = multivariate_normal([0.0, 4.0], [[1.0, 0.7], [0.7, 1.5]], size=1000000)
data[:, 0] += np.linspace(0, 1, data.shape[0])
c = ChainConsumer().add_chain(data, parameters=["$x$", "$y$"], walkers=5)
c2 = c.divide_chain()
fig = c2.plotter.plot()
fig.set_size_inches(4.5 + fig.get_size_inches()) # Resize fig for doco. You don't need this.