You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
For my current project I need a numerically-stable version of the truncated gaussian distribution in Python. I have been taking a look at the mathematical methods you detail in the file https://github.com/cossio/TruncatedNormal.jl/blob/23bfc7d0189ca6857e2e498006bbbed2a8b58be7/notes/normal.pdf for implementing the calculation of the mean and variance in a stable manner in Python.
Nonetheless, I also need a numerically stable method for calculating the log-probability of some value under the truncated gaussian (the f function you detail in the first paragraph of the PDF). Do you know how this can be done? I assume a similar method, based on Taylor expansions, could be used, but I'm not sure.
The text was updated successfully, but these errors were encountered:
functiontnlogpdf(x::Real, a::Real, b::Real)
result =-x^2/2-lognormcdf(a, b)
if x < a || x > b
returnoftype(result, -Inf)
elsereturn result -log(two(result) *pi) /2endend
Hi,
For my current project I need a numerically-stable version of the truncated gaussian distribution in Python. I have been taking a look at the mathematical methods you detail in the file https://github.com/cossio/TruncatedNormal.jl/blob/23bfc7d0189ca6857e2e498006bbbed2a8b58be7/notes/normal.pdf for implementing the calculation of the mean and variance in a stable manner in Python.
Nonetheless, I also need a numerically stable method for calculating the log-probability of some value under the truncated gaussian (the f function you detail in the first paragraph of the PDF). Do you know how this can be done? I assume a similar method, based on Taylor expansions, could be used, but I'm not sure.
The text was updated successfully, but these errors were encountered: