-
Notifications
You must be signed in to change notification settings - Fork 18
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
Create RNG module #96
Comments
I would like to help with this |
What will be the constants for the probabilities. Can you provide example? |
Also, random number generated should be both 0 and max inclusive? |
Yes, it should return in the range |
Can you better explain the last two paragraphs? |
Say
In that case,
As you can see, in this case, simply moding the result of This was addressed in #110, so no need to worry about it anymore.
There should be a header file for various constants used for things that happen with a chance. |
Right now many of the elements of RNG are hardcoded. I suggest a new RNG module, perhaps
rng.c
andrng.h
.There should be the following functions, at least:
rng_rand
should be sure to account for the limitations ofrand
in C. Namely, if the argument torng_rand
is greater thanRAND_MAX
but less thanINT_MAX
, it should piece together the result from multiplerand
calls.Further,
rng_rand
andrng_roll
should both use rejection sampling to ensure that the randomness is uniform across their respective ranges. That is,rng_rand(max)
should return every number in[0, max]
with equal probability, andrng_roll(droprate)
should always yield 1 with probability1/droprate
in the long run.Finally,
rng.h
should define the constants for various probabilities.The text was updated successfully, but these errors were encountered: