truncated_normal in brainpy.math.random calls jr.uniform to sample from a uniform distribution and then inverse the cdf to get truncated values.
jr.uniform samples from a closed interval. When lower or upper takes inf values and when jr.uniform sampled an extreme value, the inverse cdf would have inf values, which result in underflow values after clipping.
Fix: subtract and add a small value to minval and maxval arguments of jr.uniform.
How Has This Been Tested
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist
[x] Code follows the code style of this project.
[x] Changes follow the CONTRIBUTING guidelines.
[x] Update necessary documentation accordingly.
[x] Lint and tests pass locally with the changes.
[x] Check issues and pull requests first. You don't want to duplicate effort.
Description
truncated_normal
inbrainpy.math.random
callsjr.uniform
to sample from a uniform distribution and then inverse the cdf to get truncated values.jr.uniform
samples from a closed interval. Whenlower
orupper
takes inf values and whenjr.uniform
sampled an extreme value, the inverse cdf would have inf values, which result in underflow values after clipping.Fix: subtract and add a small value to
minval
andmaxval
arguments ofjr.uniform
.How Has This Been Tested
Types of changes
Checklist
Other information