You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
factory.js:427 Uncaught TypeError: invalid option. `seed` option must be either a positive integer less than or equal to the maximum unsigned 32-bit integer or an array-like object containing integer values less than or equal to the maximum unsigned 32-bit integer. Option: ``.
at Function.factory (factory.js:427:1)
at <anonymous>:1:9
However, the documentation states the valid range for a seed is [0, 4294967295]
I am using the mt19937 and beta libraries to generate pseudorandom values for a map generator. As part of that, I'm actually using mt19937 to generate random seeds that I feed back into mt19937 to generate more independent PRNGs, so it's a bit odd that the range of valid seeds is off by 1 from the range of output values. I suspect the documentation is correct and the generator is wrong.
Related Issues
Related issues # , # , and # .
Questions
No.
Demo
No response
Reproduction
import mt19937 from "@stdlib/random-base-mt19937";
mt19937.factory({seed:0})
### Expected Results
```shell
A working pseudorandom number generator
Actual Results
factory.js:427 Uncaught TypeError: invalid option. `seed` option must be either a positive integer less than or equal to the maximum unsigned 32-bit integer or an array-like object containing integer values less than or equal to the maximum unsigned 32-bit integer. Option: ``.
at Function.factory (factory.js:427:1)
at <anonymous>:1:9
@charredUtensil I believe the documentation is wrong here and the implementation correct. It is fairly common for PRNGs to not allow 0 seeds, as this can lead to degenerate starting states. From the original paper,
Since any initial seed except zero lies on the same orbit, the choice of an initial seed does not affect the randomness for the whole period.
and
Before using genrand( ), sgenrand( ) must be called with a nonzero unsigned long integer as a seed.
Also, unrelated to the documentation bug, I suggest using a different PRNG for seeding (e.g., minstd or minstd-shuffle), in order to ensure that your seeds are independent of your implementation.
Description
Calling
mt19937.factory({seed:0})
causes:However, the documentation states the valid range for a seed is
[0, 4294967295]
I am using the
mt19937
andbeta
libraries to generate pseudorandom values for a map generator. As part of that, I'm actually usingmt19937
to generate random seeds that I feed back intomt19937
to generate more independent PRNGs, so it's a bit odd that the range of valid seeds is off by 1 from the range of output values. I suspect the documentation is correct and the generator is wrong.Related Issues
Related issues # , # , and # .
Questions
No.
Demo
No response
Reproduction
Actual Results
Version
0.2.1
Environments
Firefox, Chrome
Browser Version
No response
Node.js / npm Version
No response
Platform
No response
Checklist
The text was updated successfully, but these errors were encountered: