brainpy / BrainPy

Brain Dynamics Programming in Python
https://brainpy.readthedocs.io/
GNU General Public License v3.0
508 stars 92 forks source link

fix bugs in `brainpy.math.random.truncated_normal` #574

Closed chaoming0625 closed 8 months ago

chaoming0625 commented 8 months ago
chaoming0625 commented 8 months ago

Have changed the algorithm of truncated _normal sampling using methods from

chaoming0625 commented 8 months ago

The truncated_normal is not straightforward to multiply the scale and shift the loc. I have checked the algorithms and confirmed the results using methods in https://people.sc.fsu.edu/~jburkardt/presentations/truncated_normal.pdf

chaoming0625 commented 8 months ago

One more thing, I have add the checking for the valid setting of loc, scale, upper, and lower, in order to avoid the incorrent sampling.