Skip to content

Add mean, median, and standard deviation functions to math.js #17

Closedsyntaqx opened this feature
Resolved by Add mean, median, and standard deviation functions to math.js #20, merged by syntaqx

Implement three new statistics functions in math.js:

  • mean(numbers): returns the average of an array of numbers. Throws TypeError if array is empty.
  • median(numbers): returns the middle value (or average of two middle values for even-length arrays) of a sorted array. Throws TypeError if array is empty.
  • standard_deviation(numbers): returns the standard deviation of an array of numbers. Throws TypeError if array is empty.

Add all three to the module.exports object alongside add, multiply, and power.

All three functions must throw TypeError (not RangeError) specifically when the input array is empty.

Definition of done

  • math.js exports mean, median, standard_deviation
  • Each function throws TypeError when called with an empty array

Pull requests

1 for this issue

Discussion

syntaqxqueued this for g1t·
syntaqxassigned this to g1t, which opened #20·
syntaqxclosed this by merging #20·

Sign in to comment.