Compute the mean, median, and mode of a 1D numeric array.
x: list or array - Numeric dataInput: x=[1,1,2,3]
Output: mean=1.75, median=1.5, mode=1
Input: x=[5]
Output: mean=5.0, median=5.0, mode=5
Input: x=[1,2,2,3,3]
Output: mean=2.2, median=2.0, mode=2
Use np.mean() and np.median() for mean and median.
Use Counter() to find frequencies and min() for smallest mode.
Convert all results to float() before returning.
Sign in to take notes on this problem
Accepts: array
Compute the mean, median, and mode of a 1D numeric array.
x: list or array - Numeric dataInput: x=[1,1,2,3]
Output: mean=1.75, median=1.5, mode=1
Input: x=[5]
Output: mean=5.0, median=5.0, mode=5
Input: x=[1,2,2,3,3]
Output: mean=2.2, median=2.0, mode=2
Use np.mean() and np.median() for mean and median.
Use Counter() to find frequencies and min() for smallest mode.
Convert all results to float() before returning.
Sign in to take notes on this problem
Accepts: array