UNPKG

@thi.ng/vectors

Version:

Optimized 2d/3d/4d and arbitrary length vector operations, support for memory mapping/layouts

39 lines 933 B
import type { ReadonlyVec, Vec } from "./api.js"; /** * Takes an array of vectors (of uniform dimensions) and computes the * componentwise mean. Writes result to `out` (or a new vector). * * @remarks * Also see {@link median}. * * @example * ```ts tangle:../export/mean.ts * import { mean } from "@thi.ng/vectors"; * * console.log( * mean([], [[3, 10, 400], [4, 30, 100], [1, 40, 200], [2, 20, 300]]) * ); * // [ 2.5, 25, 250 ] * ``` * * @param out - * @param src - */ export declare const mean: (out: Vec | null, src: ReadonlyVec[]) => Vec<number>; /** * Computes the mean of components of given vector. Returns 0 if vector is empty. * * @example * ```ts tangle:../export/vmean.ts * import { vmean } from "@thi.ng/vectors"; * * console.log( * vmean([5, 10, 15, 20]) * ); * // 12.5 * ``` * * @param a - */ export declare const vmean: (a: ReadonlyVec) => number; //# sourceMappingURL=mean.d.ts.map