diff options
author | tlatorre <tlatorre@uchicago.edu> | 2018-10-18 09:53:37 -0500 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2018-10-18 09:53:37 -0500 |
commit | 11a22cf650448e113d4fd16c51822dc23b9c1a33 (patch) | |
tree | f70c287a611130793d31a86acd9793a5d57bba02 /src/misc.c | |
parent | 54da09d3ec8266a5e8b95842951ddb0a67c26255 (diff) | |
download | sddm-11a22cf650448e113d4fd16c51822dc23b9c1a33.tar.gz sddm-11a22cf650448e113d4fd16c51822dc23b9c1a33.tar.bz2 sddm-11a22cf650448e113d4fd16c51822dc23b9c1a33.zip |
fix the likelihood function to return the *negative* log likelihood of the path coefficients
Previously I was adding the log likelihood of the path coefficients instead of
the *negative* log likelihood! When fitting electrons this would sometimes
cause the fit to become unstable and continue increasing the path coefficients
without bound since the gain in the likelihood caused by increasing the
coefficients was more than the loss caused by a worse fit to the PMT data.
Doh!
Diffstat (limited to 'src/misc.c')
-rw-r--r-- | src/misc.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -384,6 +384,13 @@ double logsumexp(double *a, size_t n) return amax + sum; } +double log_norm(double x, double mu, double sigma) +{ + /* Returns the log of the PDF for a gaussian random variable with mean `mu` + * and standard deviation `sigma`. */ + return -pow(x-mu,2)/(2*pow(sigma,2)) - log(sqrt(2*M_PI)*sigma); +} + double norm(double x, double mu, double sigma) { /* Returns the PDF for a gaussian random variable with mean `mu` and |