/** * Draws samples from a finite mixture: each sample comes from component i with * probability weights[i]. Components are zero-argument sampling functions or distribution * objects such as `stats.normal(0, 1)`; they may even be multivariate. * Component selection is O(1) (alias method). * * See {@link stats}.mixture for the density, cdf, quantiles and moments of a mixture. * * @example * // bimodal: 70% N(0, 1), 30% N(5, 2²) * mixture([stats.normal(0, 1), stats.normal(5, 2)], [0.7, 0.3], 1000) * mixture([() => exponential(1), () => uniform(2, 3)], [1, 3], 10) // weights are normalised * * // keep the component of each sample (e.g. to test clustering algorithms) * const { values, labels } = mixture([stats.normal(-2, 1), stats.normal(2, 1)], [0.5, 0.5], 100, { returnLabels: true }) * * @param {Array} generators - The mixture components. * @param {number[]} priors - Non-negative weights of the components (normalised automatically). * @param {number|number[]|null} [size=null] - Output shape. * @param {Object} [options] * @param {boolean} [options.returnLabels=false] - Also return the index of the component of * each sample, as `{ values, labels }`. * @returns {*|Array|{values: *, labels: *}} The samples (and labels). * @throws {Error} If the components or weights are invalid, or a component throws when sampled. */ export function mixture(generators: Array, priors: number[], size?: number | number[] | null, { returnLabels }?: { returnLabels?: boolean; }): any | any[] | { values: any; labels: any; };