-
Notifications
You must be signed in to change notification settings - Fork 66
Conversion of Noise Distribution #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
815597a
139985b
26c207a
389f9b2
306dff7
222b016
e4df934
744b3b8
60892af
b60cd33
38ca1e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| function [mu,sig] = VBA_Convert_ab(a,b) | ||
| % [mu,sig] = Convert_ab(a,b) | ||
| % | ||
| % Converts a and b defining a gamma distributed precision p to mean (mu) and | ||
| % standard deviation (sig) of the distribution over the associated standard | ||
| % deviation s, i.e. s = 1/sqrt(p) | ||
| % IN: | ||
| % a,b: Can either be a_sigma/b_sigma or a_alpha/b_alpha defining | ||
| % posterior distributions over measurement/system noise precision | ||
| % OUT: | ||
| % mu,sig: mean and standard deviation of distribution over s | ||
| % | ||
| % Be aware that this is only possible for a>1 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Convert a Gamma distribution -- defined by the shape and rate parameters a and b -- over the noise precision s into a Normal distribution -- defined by the mean and variance mu and sigma2 -- over the noise standard deviation (1/sqrt(s)). Note that this transformation is only possible for a > 1. |
||
| % | ||
| % M. Eichenlaub 13/05/2019 | ||
|
|
||
| if isinf(a) % Return 0 if system noise was switched off, i.e. a_sigma = Inf | ||
| mu=0; | ||
| sig = 0; | ||
| elseif a>1 | ||
|
||
| mu = sqrt(b)*exp(gammaln(a-0.5)-gammaln(a)); | ||
| sig = sqrt(b/(a-1)-b*exp(2*(gammaln(a-0.5)-gammaln(a)))); | ||
| else | ||
| disp('Conversion error: a<=1'); | ||
| end | ||
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,50 @@ | ||||||
| function [ a,b ] = VBA_Create_NoisePrior( mu,sig ) | ||||||
|
||||||
| function [ a,b ] = VBA_Create_NoisePrior( mu,sig ) | |
| function [a, b] = VBA_Norm2Gam (mu , sig)``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to match the doc of the other function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normal priors are usually defined in the toolbox by their mean and variance (sigma2). It shouldn't be difficult to change your code so it doesn't confuse too much the users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as above, it should be explicit that this is only a matching moment approximation of the problem
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather enforce having two parameters, return [Inf 0] if sigma is 0.
What happen if the user provides a negative mu or sig? Proper checks need to be done here, with meaningful error messages if they don't pass.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have a bit more explanations here about which a you're looking for
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be in the "check results" section
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is dangerous. If the approximation fails, this message could be lost in the logs and it would be difficult to detect where the issue comes from (or even to detect that those are weird values for a lot of users).
This case should return an error (see my other comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the name a bit pervasive...