Skip to content

Instantly share code, notes, and snippets.

@WhatIThinkAbout
Last active March 7, 2021 12:08
Show Gist options
  • Select an option

  • Save WhatIThinkAbout/8762c817239f692a15c25427829740f7 to your computer and use it in GitHub Desktop.

Select an option

Save WhatIThinkAbout/8762c817239f692a15c25427829740f7 to your computer and use it in GitHub Desktop.
Sample from a normal-gamma distribution
def sample(self):
''' sample from our estimated normal '''
precision = np.random.gamma(self.α, 1/self.β)
if precision == 0 or self.n == 0: precision = 0.001
estimated_variance = 1/precision
return np.random.normal( self.μ_0, np.sqrt(estimated_variance))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment