Created
March 24, 2020 17:19
-
-
Save VFDan/db793c15620f64ab13cbea1c0b707d6f to your computer and use it in GitHub Desktop.
Median and mean
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Math.median = (...nums) => { | |
nums.sort() | |
len = nums.length/2 | |
if (len%1) return nums[Math.floor(len)] | |
return mean(nums[len],nums[len-1]) | |
} | |
Math.mode = (...nums) => nums.reduce((a,b)=>a+b, 0)/nums.length |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment