MicroGPT.ts - a conversion of Karpathy's MicroGPT to Typescript
    Preparing search index...

    Class SeededRandom

    A deterministic pseudo-random number generator using the mulberry32 algorithm, with Box-Muller transform for Gaussian sampling and weighted random choices.

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Return a single random index chosen from weights (treated as unnormalized probabilities). Equivalent to Python's random.choices(range(n), weights=weights, k=1)[0].

      Parameters

      • weights: number[]

      Returns number

    • Return a sample from a Gaussian distribution with the given mean and standard deviation.

      Parameters

      • mean: number = 0
      • std: number = 1

      Returns number

    • Return a uniform random number in [0, 1).

      Returns number

    • Shuffle an array in-place (Fisher-Yates).

      Type Parameters

      • T

      Parameters

      • arr: T[]

      Returns T[]