Question: Python The moving average of a numeric sequence is a sequence of averages of subsequences of the original sequence; the subsequences are known as windows

Python

Python The moving average of a numeric sequence is a sequence of

The moving average of a numeric sequence is a sequence of averages of subsequences of the original sequence; the subsequences are known as windows (or a sliding window), and the length of the subsequence used is called the window size. More precisely, given a sequence s, the moving average with window size w is sequence A such that the first element in A is the average of w consecutive elements in s starting with the first, the second element in A is the average of w consecutive elements in s starting with the second, and so on until the last element in A, which is the average of w consecutive elements in s ending with the last. Example: If s [2, e, -2, 2] and w = 2, the moving average is [1, -1, 0]. 1 is the average of [2, 0], 1 is the average of e 2], and e is the average of [-2, 2] Write a function moving_average(seq, wsize) that computes and returns the moving average of seq with window size wsize

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!