ts-stats
v1.0.4
Published
Helpful utility functions for basic statistical operations
Downloads
6
Maintainers
Readme
ts-stats
Helpful utility functions for basic statistical operations 😀
Made in 🇧🇩(Bangladesh) with 💖"
Features -
- Full TypeScript Support
- Average, Max, Min, Mode, Median, Harmonic Mean
- Percentile, Range
- Variance , Standard Deviation
- Corelation
Installation
To use these utility functions in your project, you can install them via npm:
npm install ts-stats
or
yarn add ts-stats
Usage
Here's an overview of the available utility functions and how to use them:
Average (avg)
import { avg } from "ts-stats";
const numbers = [1, 2, 3, 4, 5];
const average = avg(numbers);
console.log("Average:", average);
Correlation (corelation)
import { corelation } from "ts-stats";
const dataX = [1, 2, 3, 4, 5];
const dataY = [2, 4, 6, 8, 10];
const correlation = corelation(dataX, dataY);
console.log("Correlation:", correlation);
Extrema (extrema)
import { extrema } from "ts-stats";
const numbers = [1, 2, 3, 4, 5];
const [min, max] = extrema(numbers);
console.log("Min:", min, "Max:", max);
Harmonic Mean (harmonicMean)
import { harmonicMean } from "ts-stats";
const numbers = [1, 2, 3, 4, 5];
const mean = harmonicMean(numbers);
console.log("Harmonic Mean:", mean);
Median (median)
import { median } from "ts-stats";
const numbers = [1, 2, 3, 4, 5];
const medianValue = median(numbers);
console.log("Median:", medianValue);
Mode (mode)
import { mode } from "ts-stats";
const numbers = [1, 2, 2, 3, 4, 4, 4, 5];
const modeValue = mode(numbers);
console.log("Mode:", modeValue);
Percentile (percentile)
import { percentile } from "ts-stats";
const numbers = [1, 2, 3, 4, 5];
const p90 = percentile(numbers, 90);
console.log("90th Percentile:", p90);
Range (range)
import { range } from "ts-stats";
const numbers = [1, 2, 3, 4, 5];
const rangeValue = range(numbers);
console.log("Range:", rangeValue);
Standard Deviation (stdDev)
import { stdDev } from "ts-stats";
const numbers = [1, 2, 3, 4, 5];
const deviation = stdDev(numbers);
console.log("Standard Deviation:", deviation);
Variance (variance)
import { variance } from "ts-stats";
const numbers = [1, 2, 3, 4, 5];
const varianceValue = variance(numbers);
console.log("Variance:", varianceValue);
License
This project is licensed under the GPL License - see the LICENSE file for details.