Rolling standard deviation measures local variability over consecutive windows. Use population standard deviation, so a window of k values is divided by k rather than k - 1.
For each window, first compute its mean:
μi=k1j=0∑k−1xi+jThen compute its population standard deviation:
σi=k1j=0∑k−1(xi+j−μi)2Here, i is the window's starting index and k is window_size. Return one standard deviation for every complete window.
Input: values = [1, 2, 3, 4, 5], window_size = 3
Output: [0.816497, 0.816497, 0.816497]
Explanation: Every three-value window has population variance 2/3, so each standard deviation is the square root of 2/3.
Input: values = [5, 5, 5, 5], window_size = 2
Output: [0.0, 0.0, 0.0]
Compute the mean separately for each slice of length window_size.
Take the square root after averaging the squared deviations.
Sign in to take notes on this problem
Accepts: array
Accepts: number
Rolling standard deviation measures local variability over consecutive windows. Use population standard deviation, so a window of k values is divided by k rather than k - 1.
For each window, first compute its mean:
μi=k1j=0∑k−1xi+jThen compute its population standard deviation:
σi=k1j=0∑k−1(xi+j−μi)2Here, i is the window's starting index and k is window_size. Return one standard deviation for every complete window.
Input: values = [1, 2, 3, 4, 5], window_size = 3
Output: [0.816497, 0.816497, 0.816497]
Explanation: Every three-value window has population variance 2/3, so each standard deviation is the square root of 2/3.
Input: values = [5, 5, 5, 5], window_size = 2
Output: [0.0, 0.0, 0.0]
Compute the mean separately for each slice of length window_size.
Take the square root after averaging the squared deviations.
Sign in to take notes on this problem
Accepts: array
Accepts: number