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

doc: pseudo-random-generator-next! can't return 0.0 #803

Merged
merged 1 commit into from
Feb 5, 2024

Conversation

sorawee
Copy link
Contributor

@sorawee sorawee commented Feb 5, 2024

According to the code of S_random_state_next_double at

ChezScheme/c/random.c

Lines 108 to 109 in 1f5adec

x = mrg32k3a(s);
return (x + 1.0) * norm;
(which is invoked by pseudo-random-generator-next!), the value is in the range (inclusively) 1 / (m1 + 1) to m1 / (m1 + 1). Therefore, 0.0 cannot be the result.

According to the code of `S_random_state_next_double` at
https://github.com/cisco/ChezScheme/blob/1f5adec2c18712c89eb1692458fcf5d6514bff42/c/random.c#L108-L109
(which is invoked by `pseudo-random-generator-next!`),
the value is in the range (inclusively) 1 / (m1 + 1) to m1 / (m1 + 1).
Therefore, 0.0 cannot be the result.
@burgerrg burgerrg merged commit 02c79d8 into cisco:main Feb 5, 2024
13 checks passed
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.

3 participants