/** * Picks a random element from an array based on weights. * * @template T - The type of array elements. * @param items - The array of items to pick from. * @param weights - The array of weights (positive numbers) corresponding to each item. * @returns A randomly selected item based on weights. * * @throws {Error} If items array is empty. * @throws {Error} If weights array is empty. * @throws {Error} If items and weights arrays have different lengths. * @throws {Error} If any weight is not a positive number. * @throws {Error} If any weight is NaN. * @throws {Error} If sum of weights is zero. * * @example * // Pick with equal weights * randomWeighted(['a', 'b', 'c'], [1, 1, 1]); // 'b' * * @example * // Pick with unequal weights (75% chance of 'common', 25% chance of 'rare') * randomWeighted(['common', 'rare'], [3, 1]); // 'common' * * @example * // Pick rarity level * randomWeighted(['common', 'uncommon', 'rare', 'legendary'], [50, 30, 15, 5]); * // 'uncommon' * * @note Uses Math.random() for non-cryptographic randomness. * @note Higher weight means higher probability of selection. * @note Weights don't need to sum to 1 or 100 - they are normalized internally. * * @complexity Time: O(n), Space: O(1) where n is array length */ export declare function randomWeighted(items: T[], weights: number[]): T; //# sourceMappingURL=randomWeighted.d.ts.map