Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 8 commits into from
Jan 2, 2024
Merged

Conversation

chaoming0625
Copy link
Collaborator

  • fix bugs in brainpy.math.random.truncated_normal
  • copy random doc of numpy for better readability

Copy link
Collaborator

@charlielam0615 charlielam0615 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments and happy new year!

brainpy/_src/math/random.py Show resolved Hide resolved
brainpy/_src/math/random.py Show resolved Hide resolved
brainpy/_src/math/random.py Outdated Show resolved Hide resolved
@chaoming0625
Copy link
Collaborator Author

Have changed the algorithm of truncated _normal sampling using methods from

@chaoming0625
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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.

@chaoming0625 chaoming0625 merged commit 256cb27 into master Jan 2, 2024
32 checks passed
@chaoming0625 chaoming0625 deleted the fix-random branch January 2, 2024 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants