Last active
March 3, 2021 13:36
-
-
Save WhatIThinkAbout/bdc845f1e080a0849d2816b773eda0fa to your computer and use it in GitHub Desktop.
Update the hyper-parameters for unknown 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 | |
| mean and variance by combining the single new value 'x' with the current estimate ''' | |
| n = 1 | |
| v = self.n | |
| self.α = self.α + n/2 | |
| self.β = self.β + ((n*v/(v + n)) * (((x - self.μ_0)**2)/2)) | |
| # estimate the variance - calculate the mean from the gamma hyper-parameters | |
| self.v_0 = self.β / (self.α + 1) | |
| self.x.append(x) # append the new value to the list of samples | |
| self.n += 1 | |
| self.μ_0 = np.array(self.x).mean() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment