Last active
March 5, 2021 16:56
-
-
Save WhatIThinkAbout/6927bd8a71bb8964e3ed3d1e89b150df to your computer and use it in GitHub Desktop.
Update function for conjugate prior hyper-parameters for normal distribution with known mean and unknown variance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def update(self,x): | |
| ''' increase the number of times this socket has been used and improve the estimate of the | |
| variance by updating the gamma distribution's hyper-parameters using the new value 'x' ''' | |
| self.n += 1 | |
| self.x.append(x) # append the new value to the list of samples | |
| self.α = self.n/2 | |
| self.β = ((np.array(self.x) - self.μ)**2).sum()/2 | |
| # estimate the variance from the gamma hyper-parameters | |
| self.v_0 = self.β / (self.α + 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment