Compute the trailing rolling mean of width window: position i holds the mean of the last window values ending at i. The first window - 1 positions do not have a full window yet.
Implement solve(x, window).
Returns. Return a float NumPy array the same length as x, with NaN in the first window - 1 positions. window must be at least 1 (otherwise ValueError); a window longer than x gives all NaN.
Example 1
Input:
solve([1.0, 2.0, 3.0, 4.0], 2)
Output:
[nan, 1.5, 2.5, 3.5]
Example 2
Input:
solve([2.0, 4.0, 6.0, 8.0, 10.0], 3)
Output:
[nan, nan, 4.0, 6.0, 8.0]
No results yet
Run your code to check it against the examples, or submit to run every test.