/** * Generates a random sample from a given array or from `range(n)`, as numpy's `choice`. * * @example * choice(['a', 'b', 'c']) // one element * choice(['a', 'b'], [0.9, 0.1], 10) // ten weighted draws * choice(52, null, 5, false) // five distinct cards out of 52 * choice(['x', 'y', 'z'], [5, 1, 1], 2, false) // weighted, without replacement * * @param {Array|number} array - Population, or an integer `n` meaning `[0, 1, ..., n-1]`. * @param {number[]|null} [weights=null] - Non-negative weights (normalised automatically). * Uniform when `null`. * @param {number|number[]|null} [size=null] - Output shape. `null` returns a single element. * @param {boolean} [replace=true] - Whether the sample is with replacement. * @returns {*|Array} The sampled element(s). * @throws {Error} If the population is empty, the weights are invalid, or more elements * than available are requested without replacement. */ export function choice(array: any[] | number, weights?: number[] | null, size?: number | number[] | null, replace?: boolean): any | any[];