source: node_modules/es-toolkit/dist/math/median.d.ts

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 869 bytes
Line 
1/**
2 * Calculates the median of an array of numbers.
3 *
4 * The median is the middle value of a sorted array.
5 * If the array has an odd number of elements, the median is the middle value.
6 * If the array has an even number of elements, it returns the average of the two middle values.
7 *
8 * If the array is empty, this function returns `NaN`.
9 *
10 * @param {number[]} nums - An array of numbers to calculate the median.
11 * @returns {number} The median of all the numbers in the array.
12 *
13 * @example
14 * const arrayWithOddNumberOfElements = [1, 2, 3, 4, 5];
15 * const result = median(arrayWithOddNumberOfElements);
16 * // result will be 3
17 *
18 * @example
19 * const arrayWithEvenNumberOfElements = [1, 2, 3, 4];
20 * const result = median(arrayWithEvenNumberOfElements);
21 * // result will be 2.5
22 */
23declare function median(nums: readonly number[]): number;
24
25export { median };
Note: See TracBrowser for help on using the repository browser.