Python pymc3.traceplot() Examples
The following are 3
code examples of pymc3.traceplot().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pymc3
, or try the search function
.
Example #1
Source File: stochastic_volatility.py From fin with MIT License | 5 votes |
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()
Example #2
Source File: GaussianProcessMCMC.py From pyGPGO with MIT License | 5 votes |
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()
Example #3
Source File: tStudentProcessMCMC.py From pyGPGO with MIT License | 5 votes |
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()