import { prng } from 'seedrandom'; export default class StdRandom { static _seed: number; static _random: prng; /** * Sets the seed of the pseudo-random number generator. * This method enables you to produce the same sequence of "random" * number for each execution of the program. * Ordinarily, you should call this method at most once per program. * * @param seed the seed */ static setSeed(seed: number): void; /** * Returns a random real number uniformly in [0, 1). * * @return a random real number uniformly in [0, 1) */ static random(): number; /** * Get random number from a to b(not included), [a, b). * If b is omitted, the range is [0, a) * @param a * @param b */ static uniform(a?: number, b?: number): number; /** * Returns a random boolean from a Bernoulli distribution with success * probability **p**. * @param p probability, 0 ~ 1, e.g. 0.25 */ static bernoulli(p: number): boolean; /** * Returns a random real number from a Gaussian distribution with mean μ * and standard deviation σ. * * @param mu the mean * @param sigma the standard deviation * @return a real number distributed according to the Gaussian distribution */ static gaussian(mu?: number, sigma?: number): number; /** * Returns a random integer from the specified discrete distribution. * * @param probabilities the probability of occurrence of each integer * @return a random integer from a discrete distribution: * i with probability probabilities[i] * @throws Error if probabilities is null * @throws Error if sum of array entries is not (very nearly) equal to 1.0 * @throws Error unless probabilities[i] >= 0.0 for each index i */ static discrete(probabilities: number[]): number; /** * Shuffle array * @param arr */ static shuffle(arr: Array): void; }