/** * Generates random vectors x = μ + L z, where Σ = L Lᵀ is the Cholesky factorisation of the * covariance matrix and z is a noise vector with independent zero-mean unit-variance components * produced by `noiseGenerator`. The result has mean μ and covariance Σ whatever the noise * distribution (normal noise gives the multivariate normal distribution). * * @param {number[]} means - Array of means (μ) for each dimension. * @param {number[][]} covariance - Covariance matrix (Σ). Must be symmetric positive * semi-definite and match the length of `means`. * @param {Function} noiseGenerator - Function receiving the dimension `n` and returning a * noise vector of length `n`: `noiseGenerator(n) → number[]`. * @param {number|number[]|null} [size=null] - Output shape: * - `null`: a single sample vector. * - `k`: an array of `k` sample vectors. * - `[m, k]`: a nested array of shape m x k of sample vectors. * @returns {number[]|number[][]|Array} Sample vector(s). * @throws {Error} If the shapes are invalid, the covariance is not positive semi-definite, * `noiseGenerator(n)` does not return a vector of length `n` or `size` is invalid. */ export function multivariate(means: number[], covariance: number[][], noiseGenerator: Function, size?: number | number[] | null): number[] | number[][] | any[];