Skip to content

Non-uniform BigInt distributions #13

@tabatkins

Description

@tabatkins

The current proposal has Random.bigint(), which generates a uniform BigInt in a range. All the rest of the proposed number-returning functions, particularly the non-uniform distributions like Random.normal(), return Numbers.

In #8, tho, @michaelficarra mentions wanting non-uniform distributions over BigInts. How can we best address this?

  • Should we have normalBigInt()/etc variants?
  • The alternative is just saying "eh, BigInt(Math.round(Random.foo(...))) is good enough".

Are the use-cases for non-uniform BigInt distributions outside of the ±2^53 range large enough to need an API solution? Is it sufficient to just shift your distribution to within the SAFE_INTEGER range, generate a Number, convert to BigInt, then shift back? The only weakness is if you need integer-accurate values where the whole meaningful range is wider than 2^54.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions