def init(self, shared, group=None): """ Draw samples from the marginal posteriors of mu and sigmasq \cite{murphy2007conjugate}, Eqs. 156 & 167 """ post = shared if group is None else shared.plus_group(group) # Sample from the inverse-chi^2 using the transform from the chi^2 sigmasq_star = post.nu * post.sigmasq / sample_chi2(post.nu) self.sigma = sqrt(sigmasq_star) self.mu = sample_normal(post.mu, sqrt(sigmasq_star / post.kappa))
def sampler_create(self, group=None): """ Draw samples from the marginal posteriors of mu and sigmasq \cite{murphy2007conjugate}, Eqs. 156 & 167 """ post = self if group is None else self.plus_group(group) # Sample from the inverse-chi^2 using the transform from the chi^2 sigmasq_star = post.nu * post.sigmasq / sample_chi2(post.nu) mu_star = sample_normal(post.mu, sqrt(sigmasq_star / post.kappa)) return (mu_star, sigmasq_star)
def eval(self, shared): return sample_normal(self.mu, self.sigma)
def sampler_eval(self, sampler): mu, sigmasq = sampler return sample_normal(mu, sqrt(sigmasq))