Robust scaling centers values by their median and scales them by the interquartile range. These statistics are less sensitive to extreme values than the mean and standard deviation.
xscaled=Q3−Q1x−Q2Here, Q_2 is the median, Q_1 is the median of the lower half, and Q_3 is the median of the upper half. Exclude the overall median from both halves when the input length is odd. If the interquartile range is zero, return each value minus the median without division.
Input: values = [1, 2, 3, 4, 5]
Output: [-0.6667, -0.3333, 0.0, 0.3333, 0.6667]
Explanation: The median is 3, the lower and upper quartiles are 1.5 and 4.5, and the interquartile range is 3.
Input: values = [10, 20, 30, 40]
Output: [-0.75, -0.25, 0.25, 0.75]
Write a small helper that returns the median of an already sorted list.
Form the lower and upper halves before computing their medians.
Sign in to take notes on this problem
Accepts: array
Robust scaling centers values by their median and scales them by the interquartile range. These statistics are less sensitive to extreme values than the mean and standard deviation.
xscaled=Q3−Q1x−Q2Here, Q_2 is the median, Q_1 is the median of the lower half, and Q_3 is the median of the upper half. Exclude the overall median from both halves when the input length is odd. If the interquartile range is zero, return each value minus the median without division.
Input: values = [1, 2, 3, 4, 5]
Output: [-0.6667, -0.3333, 0.0, 0.3333, 0.6667]
Explanation: The median is 3, the lower and upper quartiles are 1.5 and 4.5, and the interquartile range is 3.
Input: values = [10, 20, 30, 40]
Output: [-0.75, -0.25, 0.25, 0.75]
Write a small helper that returns the median of an already sorted list.
Form the lower and upper halves before computing their medians.
Sign in to take notes on this problem
Accepts: array