Skip to content

Commit

Permalink
add in horseshoe distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
xjing76 committed Oct 12, 2021
1 parent bb8b644 commit c5a18c2
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pymc3_hmm/distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,3 +452,29 @@ def logp(self, value):

def _distr_parameters_for_repr(self):
return ["c"]


class HorseShoe(pm.Normal):
"""
A Horseshoe distribution
"""

def __init__(self, tau, shape, **kwargs):
self.tau = tau
self.beta_raw = pm.Normal.dist(tau=1, shape=shape)
self.lmbda = pm.HalfCauchy.dist(beta=1, shape=shape)
super().__init__(shape=shape, **kwargs)

def random(self, point=None, size=None):
beta_raw = self.beta_raw.random(point=point, size=size)
lmbda = self.lmbda.random(point=point, size=size)
return beta_raw * lmbda * self.tau

def logp(self, values):
"""
Place holder for horseshoe logp as we are not be needing this func
"""
return 1


0 comments on commit c5a18c2

Please sign in to comment.