Skip to content

mt19937.factory does not accept 0 as a seed #1963

Closed
@charredUtensil

Description

@charredUtensil

Description

Calling mt19937.factory({seed:0}) causes:

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

Version

0.2.1

Environments

Firefox, Chrome

Browser Version

No response

Node.js / npm Version

No response

Platform

No response

Checklist

  • Read and understood the Code of Conduct.
  • Searched for existing issues and pull requests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working.DocumentationImprovements, additions, or changes to documentation.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions