本文整理汇总了Python中chainconsumer.ChainConsumer.add_chain方法的典型用法代码示例。如果您正苦于以下问题:Python ChainConsumer.add_chain方法的具体用法?Python ChainConsumer.add_chain怎么用?Python ChainConsumer.add_chain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chainconsumer.ChainConsumer
的用法示例。
在下文中一共展示了ChainConsumer.add_chain方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_all_no_weight
# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import add_chain [as 别名]
def plot_all_no_weight(folder, output):
""" Plot all chains as one, with and without weights applied """
print("Plotting all as one, with old and new weights")
chain, posterior, t, p, f, l, w, ow = load_stan_from_folder(folder, merge=True)
c = ChainConsumer()
c.add_chain(chain, posterior=posterior, walkers=l)
c.plot(filename=output, truth=t, figsize=0.75)
示例2: plot_results
# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import add_chain [as 别名]
def plot_results(chain, param, chainf, chainf2, paramf, t0, x0, x1, c, temp_dir, seed, interped):
cc = ChainConsumer()
cc.add_chain(chain, parameters=param, name="Posterior")
cc.add_chain(chainf, parameters=paramf, name="Minuit")
cc.add_chain(chainf2, parameters=paramf, name="Emcee")
truth = {"$t_0$": t0, "$x_0$": x0, "$x_1$": x1, "$c$": c, r"$\mu$": get_mu(interped, x0, x1, c)}
cc.plot(filename=temp_dir + "/surfaces_%d.png" % seed, truth=truth)
示例3: debug_plots
# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import add_chain [as 别名]
def debug_plots(std):
print(std)
res = load_stan_from_folder(std, merge=True, cut=False)
chain, posterior, t, p, f, l, w, ow = res
print(w.mean(), np.std(w), np.mean(np.log(w)), np.std(np.log(w)))
# import matplotlib.pyplot as plt
# plt.hist(np.log(w), 100)
# plt.show()
# exit()
logw = np.log(w)
m = np.mean(logw)
s = np.std(logw)
print(m, s)
logw -= (m + 3 * s)
good = logw < 0
logw *= good
w = np.exp(logw)
sorti = np.argsort(w)
for key in chain.keys():
chain[key] = chain[key][sorti]
w = w[sorti]
ow = ow[sorti]
posterior = posterior[sorti]
c = ChainConsumer()
truth = [0.3, 0.14, 3.1, -19.365, 0, 0, 0.1, 1.0, 0.1, 0, 0, 0, 0, 0, 0]
c.add_chain(chain, name="uncorrected", posterior=posterior)
c.add_chain(chain, weights=w, name="corrected", posterior=posterior)
c.plot(filename="output.png", parameters=9, truth=truth, figsize=1.3)
# c = ChainConsumer()
# c.add_chain(chain, weights=w, name="corrected")
c.plot_walks(chains="corrected", filename="walks.png", truth=truth)
示例4: test_bic_fail_no_posterior
# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import add_chain [as 别名]
def test_bic_fail_no_posterior():
d = norm.rvs(size=1000)
c = ChainConsumer()
c.add_chain(d, num_eff_data_points=1000, num_free_params=1)
bics = c.comparison.bic()
assert len(bics) == 1
assert bics[0] is None
示例5: test_get_chain_via_object
# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import add_chain [as 别名]
def test_get_chain_via_object(self):
c = ChainConsumer()
c.add_chain(self.data, name="A")
c.add_chain(self.data, name="B")
assert c._get_chain(c.chains[0])[0] == 0
assert c._get_chain(c.chains[1])[0] == 1
assert len(c._get_chain(c.chains[0])) == 1
assert len(c._get_chain(c.chains[1])) == 1
示例6: test_aic_0
# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import add_chain [as 别名]
def test_aic_0():
d = norm.rvs(size=1000)
p = norm.logpdf(d)
c = ChainConsumer()
c.add_chain(d, posterior=p, num_free_params=1, num_eff_data_points=1000)
aics = c.comparison.aic()
assert len(aics) == 1
assert aics[0] == 0
示例7: test_dic_0
# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import add_chain [as 别名]
def test_dic_0():
d = norm.rvs(size=1000)
p = norm.logpdf(d)
c = ChainConsumer()
c.add_chain(d, posterior=p)
dics = c.comparison.dic()
assert len(dics) == 1
assert dics[0] == 0
示例8: plot_separate
# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import add_chain [as 别名]
def plot_separate(folder, output):
""" Plot separate cosmologies """
print("Plotting all cosmologies separately")
res = load_stan_from_folder(folder, merge=False)
c = ChainConsumer()
for i, (chain, posterior, t, p, f, l, w, ow) in enumerate(res):
c.add_chain(chain, weights=w, posterior=posterior, walkers=l, name="%d"%i)
c.plot(filename=output, truth=t, figsize=0.75)
示例9: plot_single_cosmology_weight
# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import add_chain [as 别名]
def plot_single_cosmology_weight(folder, output, i=0):
print("Plotting cosmology realisation %d" % i)
res = load_stan_from_folder(folder, merge=False)
c = ChainConsumer()
chain, posterior, t, p, f, l, w, ow = res[i]
c.add_chain(chain, posterior=posterior, walkers=l, name="Uncorrected %d"%i)
c.add_chain(chain, weights=w, posterior=posterior, walkers=l, name="Corrected %d"%i)
c.plot(filename=output, truth=t, figsize=0.75)
示例10: test_bic_fail_no_num_params
# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import add_chain [as 别名]
def test_bic_fail_no_num_params():
d = norm.rvs(size=1000)
p = norm.logpdf(d)
c = ChainConsumer()
c.add_chain(d, posterior=p, num_eff_data_points=1000)
bics = c.comparison.bic()
assert len(bics) == 1
assert bics[0] is None
示例11: test_shade_alpha_algorithm2
# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import add_chain [as 别名]
def test_shade_alpha_algorithm2(self):
consumer = ChainConsumer()
consumer.add_chain(self.data)
consumer.add_chain(self.data)
consumer.configure()
alpha0 = consumer.chains[0].config["shade_alpha"]
alpha1 = consumer.chains[0].config["shade_alpha"]
assert alpha0 == 1.0 / 2.0
assert alpha1 == 1.0 / 2.0
示例12: is_unconstrained
# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import add_chain [as 别名]
def is_unconstrained(chain, param):
c = ChainConsumer()
c.add_chain(chain, parameters=param)
constraints = c.get_summary()[0]
for key in constraints:
val = constraints[key]
if val[0] is None or val[2] is None:
return True
return False
示例13: plot_all
# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import add_chain [as 别名]
def plot_all(folder, output, output_walk=None):
""" Plot all chains as one """
print("Plotting all as one")
chain, posterior, t, p, f, l, w, ow = load_stan_from_folder(folder, merge=True)
c = ChainConsumer()
c.add_chain(chain, weights=w, posterior=posterior, walkers=l)
c.plot(filename=output, truth=t, figsize=0.75)
if output_walk is not None:
c.plot_walks(filename=output_walk)
示例14: test_shade_alpha_algorithm3
# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import add_chain [as 别名]
def test_shade_alpha_algorithm3(self):
consumer = ChainConsumer()
consumer.add_chain(self.data)
consumer.add_chain(self.data)
consumer.add_chain(self.data)
consumer.configure()
alphas = [c.config["shade_alpha"] for c in consumer.chains]
assert len(alphas) == 3
assert alphas[0] == 1.0 / 3.0
assert alphas[1] == 1.0 / 3.0
assert alphas[2] == 1.0 / 3.0
示例15: test_bic_data_dependence2
# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import add_chain [as 别名]
def test_bic_data_dependence2():
d = norm.rvs(size=1000)
p = norm.logpdf(d)
c = ChainConsumer()
c.add_chain(d, posterior=p, num_free_params=2, num_eff_data_points=1000)
c.add_chain(d, posterior=p, num_free_params=3, num_eff_data_points=500)
bics = c.comparison.bic()
assert len(bics) == 2
assert bics[0] == 0
expected = 3 * np.log(500) - 2 * np.log(1000)
assert np.isclose(bics[1], expected, atol=1e-3)