当前位置: 首页>>代码示例>>Python>>正文


Python ChainConsumer.divide_chain方法代码示例

本文整理汇总了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)
开发者ID:dessn,项目名称:sn-bhm,代码行数:32,代码来源:efficiency_model_6.py

示例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.
开发者ID:Samreay,项目名称:ChainConsumer,代码行数:32,代码来源:plot_divide_chain.py


注:本文中的chainconsumer.ChainConsumer.divide_chain方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。