2024-05-15 01:18:37 发布
网友
在尝试Stan 8学校示例程序时,使用拟合图(). https://pystan.readthedocs.io/en/latest/getting_started.html
我已经安装了matplotlib和它们提供的示例plot。 我在macOS iterm上运行它。你知道吗
它不见了节目(). 我已经在下面粘贴了完整的代码。你知道吗
import pystan import matplotlib.pyplot as plt schools_code = """ data { int<lower=0> J; // number of schools real y[J]; // estimated treatment effects real<lower=0> sigma[J]; // s.e. of effect estimates } parameters { real mu; real<lower=0> tau; real eta[J]; } transformed parameters { real theta[J]; for (j in 1:J) theta[j] = mu + tau * eta[j]; } model { eta ~ normal(0, 1); y ~ normal(theta, sigma); } """ schools_dat = {'J': 8, 'y': [28, 8, -3, 7, -1, 1, 18, 12], 'sigma': [15, 10, 16, 11, 9, 11, 10, 18]} sm = pystan.StanModel(model_code=schools_code) fit = sm.sampling(data=schools_dat, iter=1000, chains=4) print(fit) fit.plot() plt.show()
它不见了节目(). 我已经在下面粘贴了完整的代码。你知道吗
相关问题 更多 >
编程相关推荐