x, wing = check_inputs(x, width)
// Pre-allocate the result array
result = np.empty_like(x)
// Keep a copy of the rolling window in original order; initially fill with
// a mirrored copy of the first "wing" points
window = deque(np.concatenate((x[wing::-1], x[:wing])))
// Also keep a sorted copy of the rolling window values
After Change
x, wing = check_inputs(x, width)
// Pad the edges of the original array with mirror copies
signal = np.concatenate((x[wing-1::-1], x, x[:-wing-1:-1]))
rolled = pd.rolling_median(signal, 2 * wing + 1, center=True)
return rolled[wing:-wing]
def rolling_quantile(x, width, quantile):
Rolling quantile (0--1) with mirrored edges.