This TypeScript module provides a set of functions for performing basic statistical operations on arrays of numbers.
To use these functions, include the module in your TypeScript project. Ensure you have TypeScript installed and configured.
Computes the average of an array of numbers.
Example:
import { average } from './stats';
console.log(average([1, 2, 3, 4, 7])); // Outputs: 3.4
Computes the variance of an array of numbers.
Example:
import { variance } from './stats';
console.log(variance([1, 2, 3, 4, 7])); // Outputs: 4.24
Computes the standard deviation of an array of numbers.
Example:
import { stdDev } from './stats';
console.log(stdDev([1, 2, 3, 4, 7])); // Outputs: 2.06
Finds the median of an array of numbers.
Example:
import { median } from './stats';
console.log(median([1, 2, 3, 4, 7])); // Outputs: 3
Finds the mode of an array of numbers.
Example:
import { mode } from './stats';
console.log(mode([1, 2, 3, 4, 7, 7, 7, 7])); // Outputs: 7
Computes the range of an array of numbers.
Example:
import { range } from './stats';
console.log(range([1, 2, 3, 4, 7])); // Outputs: 6
Computes the covariance of two arrays of numbers.
Example:
import { covariance } from './stats';
console.log(covariance([1, 2, 3, 4, 7], [1, 2, 3, 4, 7])); // Outputs: 4.24
Contributions to improve the module are welcome. Please follow the standard GitHub pull request process to propose changes.