Closed JJMorton closed 3 years ago
Hi, thanks for spotting this,
Is it handled similarly in scipy? If yes, could you perhaps file a pull request?
Originally I wanted to maintain differentiability of moments wrt the parameters, but I'm guessing a
and/or b
being -inf
and inf
respectively is a reasonable case which should allow backprop only wrt finite parameters of the distribution.
Thanks,
Anton
I'm not familiar enough with scipy to be sure how it internally handles cases like this, but this fix yields the same behaviour as far as I've tested. I'll submit a pull request.
Fixed in #5
Hi,
It seems that when
a
orb
are defined asmath.inf
, the variance becomes undefined. Unless I am missing something, the variance should still be well defined for these casesFor example, comparing to the equivalent scipy function
scipy.stats.truncnorm
:scipy.stats.truncnorm(a=-0.5, b=math.inf, loc=7500, scale=15000)
gives variance 1.1E+08TruncatedNormal(a=-0.5, b=math.inf, loc=7500, scale=15000)
gives variance NaNI believe it comes down to the line
Little phi is correctly calculated as zero for the infinite limit, but
0 * math.inf
results in a NaN.As a quick fix, I replaced infinities with zeros in the line above, for example: