本文整理匯總了Python中pymc3.traceplot方法的典型用法代碼示例。如果您正苦於以下問題:Python pymc3.traceplot方法的具體用法?Python pymc3.traceplot怎麽用?Python pymc3.traceplot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pymc3
的用法示例。
在下文中一共展示了pymc3.traceplot方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: import pymc3 [as 別名]
# 或者: from pymc3 import traceplot [as 別名]
def main():
#load data
returns = data.get_data_google('SPY', start='2008-5-1', end='2009-12-1')['Close'].pct_change()
returns.plot()
plt.ylabel('daily returns in %');
with pm.Model() as sp500_model:
nu = pm.Exponential('nu', 1./10, testval=5.0)
sigma = pm.Exponential('sigma', 1./0.02, testval=0.1)
s = pm.GaussianRandomWalk('s', sigma**-2, shape=len(returns))
r = pm.StudentT('r', nu, lam=pm.math.exp(-2*s), observed=returns)
with sp500_model:
trace = pm.sample(2000)
pm.traceplot(trace, [nu, sigma]);
plt.show()
plt.figure()
returns.plot()
plt.plot(returns.index, np.exp(trace['s',::5].T), 'r', alpha=.03)
plt.legend(['S&P500', 'stochastic volatility process'])
plt.show()
示例2: posteriorPlot
# 需要導入模塊: import pymc3 [as 別名]
# 或者: from pymc3 import traceplot [as 別名]
def posteriorPlot(self):
"""
Plots sampled posterior distributions for hyperparameters.
"""
with self.model as model:
pm.traceplot(self.trace, varnames=['l', 'sigmaf', 'sigman'])
plt.tight_layout()
plt.show()
示例3: posteriorPlot
# 需要導入模塊: import pymc3 [as 別名]
# 或者: from pymc3 import traceplot [as 別名]
def posteriorPlot(self):
"""
Plots sampled posterior distributions for hyperparameters.
"""
with self.model as model:
pm.traceplot(self.trace, varnames=['l', 'sigmaf', 'sigman'])
plt.tight_layout()
plt.show()