-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Adds PCG32 random generator, makes it default #4536
Conversation
src/random/pcg.cr
Outdated
@@ -0,0 +1,80 @@ | |||
# This is a Crystal conversion of basic C PCG implementation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest naming this file with full algo name, like pcg32.cr
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming is because there also exists PCG64 and some variations with different seeding that share most of code, so i thought that they could be added to this file later. On the other hand, right now it doesn't make sense so i'll change it.
I'm totally fine with this, obviously. Performance and quality is greatly improved. I'd like the opinion of others on this. |
@konovod I like this, thank you! I don't know much about random number generators, but the comments in #4493 and links to papers seem to be good. If we merge this, I'd like to move other PRNG to shards. I think it's better to just have a single good random number generator in the standard library (and a good secure one too), but that's it, so users don't feel overwhelmed. If they need a specific one for their characteristics they can find an external shard. |
@asterite presumably they would live on the crystal-lang org so that users knew they had good support? |
I'm not sure. I don't want to maintain that. |
i've added Mersenne Twister and ISAAC to prngs as it's, well, just copying a files 😆 |
Random generator implementations strike me as pretty low maintenance. They can't really get more features and bugs are likely rare as we can compare directly vs existing implementations. Due to their nature it's unlikely that corner cases exist. |
Well, there have been a bunch of PRs related to PRNG, so I'd like to disagree on that 😸 In any case, we can leave the implementations in the std... but at least I won't maintain them. |
@asterite Have there? I only recall one or two adding a new PRNG and none modifying the PRNG code. |
@asterite you said this is pretty good looking, how about we merge this? 😄 |
Thank you @konovod! |
@mverzilli thanks 👍 @konovod |
Implementation of #4493
I've changed Random::DEFAULT to PCG32 as it looks pointless to add better (for most use cases) generator without making it default.