Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed ar1 logp to use ar1 precision instead of innovation precision #3899

Merged
merged 13 commits into from
Jun 11, 2020
5 changes: 3 additions & 2 deletions pymc3/distributions/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ def logp(self, x):
TensorVariable
"""
k = self.k
tau_e = self.tau_e
tau_e = self.tau_e #innovation precision
ljmartin marked this conversation as resolved.
Show resolved Hide resolved
tau = tau_e * (1 - k ** 2) #ar1 precision
ljmartin marked this conversation as resolved.
Show resolved Hide resolved

x_im1 = x[:-1]
x_i = x[1:]
boundary = Normal.dist(0., tau=tau_e).logp
boundary = Normal.dist(0., tau=tau).logp

innov_like = Normal.dist(k * x_im1, tau=tau_e).logp(x_i)
return boundary(x[0]) + tt.sum(innov_like)
Expand Down
3 changes: 2 additions & 1 deletion pymc3/tests/test_distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ def mvt_logpdf(value, nu, Sigma, mu=0):
return logp.sum()

def AR1_logpdf(value, k, tau_e):
return (sp.norm(loc=0, scale=1/np.sqrt(tau_e)).logpdf(value[0]) +
tau = tau_e * (1 - k ** 2)
return (sp.norm(loc=0, scale=1/np.sqrt(tau)).logpdf(value[0]) +
sp.norm(loc=k*value[:-1], scale=1/np.sqrt(tau_e)).logpdf(value[1:]).sum())

def invlogit(x, eps=sys.float_info.epsilon):
Expand Down