UNPKG

@handy-common-utils/misc-utils

Version:
22 lines 1.45 kB
/** * Distributes an array into a number of groups in a round robin fashion. * This function has been tuned for performance. * @param array The input array * @param groups Number of groups the elements in the input array need to be distributed into. * @returns The result as an array of arrays which each represents a group */ export declare function distributeRoundRobin<T>(array: Array<T>, groups: number): Array<Array<T>>; /** * Down samples the input array randomly. * @param array The input array * @param numSamples Number of samples to be taken from the input array. * If the number of samples is greater than or equal to the length of the input array, * the output array will contain all the elements in the input array. * @param probabilityTransformerFunction A function that turns a random number within [0, 1) to another number within [0, 1). * If not provided, the identity function F(x) = x will be used. * The probability of an element being selected from the input array is determined by this function. * @returns A new array with the down sampled elements from the input array. * The order of the elements in the output array is the same as the input array. */ export declare function downSampleRandomly<T>(array: Array<T>, numSamples: number, probabilityTransformerFunction?: ((x: number) => number)): Array<T>; //# sourceMappingURL=array.d.ts.map