@neutrium/rand API - v2.0.0
    Preparing search index...

    Class Philox4x32

    Shared base implementation for random generators.

    Concrete generators must implement next_u32() and can reuse the helper methods here for generating floats, arrays, bytes, and statistical samples.

    Hierarchy (View Summary)

    Index
    • Generate the requested count of bytes.

      This method consumes 32-bit random values and emits them as bytes.

      Parameters

      • count: number

        number of bytes to generate

      Returns Uint8Array

      filled Uint8Array

    • Release resources owned by the generator.

      JavaScript generators do not own external resources, so their default implementation is a no-op. Resource-backed subclasses override it.

      Returns void

    • Generate an exponentially distributed random value.

      Parameters

      • rate: number = 1

        positive rate parameter

      Returns number

      exponentially distributed random value

    • Fill a typed random array with values.

      • Uint32Array: raw 32-bit values
      • Float32Array: values in [0, 1)
      • Float64Array: values formed from pairs of 32-bit words

      Type Parameters

      Parameters

      • target: T

        array to fill

      Returns T

      the filled array

    • Create a Float32Array containing the requested count of random values in [0, 1).

      Parameters

      • count: number

        number of elements to generate

      Returns Float32Array

      filled Float32Array

    • Create a Float64Array containing the requested count of random values in [0, 1).

      Parameters

      • count: number

        number of values to generate

      Returns Float64Array

      filled Float64Array

    • Generate an unbiased integer in the range [0, max_exclusive).

      Rejects high values that would bias the result when the range does not evenly divide the 32-bit space.

      Parameters

      • max_exclusive: number

        exclusive upper bound for the generated integer

      Returns number

      random integer in [0, max_exclusive)

    • Generate the next floating-point random value in [0, 1).

      This method is the default random value generator and delegates to next_f64() for full double-precision output.

      Returns number

    • Generate a 64-bit-quality floating-point random value in [0, 1).

      Combines two 32-bit random values to produce a 53-bit mantissa for a standard JavaScript double precision result.

      Returns number

    • Generate a normally distributed random value.

      The result uses the Box-Muller transform with the specified mean and standard deviation.

      Parameters

      • mean: number = 0

        distribution mean

      • standard_deviation: number = 1

        distribution standard deviation

      Returns number

      normally distributed random value

    • Create a Uint32Array containing the requested count of raw 32-bit random values.

      Parameters

      • count: number

        number of elements to generate

      Returns Uint32Array

      filled Uint32Array