Question: Specific things we would like this function to do: a) Take in three arguments/inputs, in this order: 1) An input dataset (make it a 1-

Specific things we would like this function to do:

a) Take in three arguments/inputs, in this order: 1) An input dataset (make it a 1- or 2D numpy array), 2) a flag for which parameter to calculate, where 1 = mean, 2 = SD and 3 = correlation and 3) the window size (the subset of how many numbers of the dataset to compute the parameter indicated in 2) over).

b) Calculate the parameter described in a2 for the data in a1 over the window size specified in a3. For instance, if we give an input of a 1D numpy array with length 100 numbers, and ask it to calculate the mean, with a window size of 20, the function should calculate the mean from the beginning of the input array (index 0) to location 19, then from location 1 to 20, then from location 2 to 21, and so on, until the last 20 entries in the data array yield the last mean. You can assume an overlap of windowsize-1, so only shift the window by 1 position per calculation.

c) The outputs of this sliding windowed calculation should be assigned to an output array, with one entry, e.g. the mean, sd or correlation per calculation. This output array will be somewhat shorter than the input array, as the sliding should stop once the window hits the end of the input array. Don't zero-pad.

d) The function should return the output array from c), once all calculations are done.

e) The function should be flexible, i.e. output the windowed mean if the input flag in a2 is 1, the windowed SD if it is 2 and the windowed correlation if it is 3.

f) Assumptions: You can assume that the input will be a 2D array (with variables in columns and measures/numbers in rows) if the a2 flag is correlation and a 1D array if the a2 flag is mean or sd.

g) Make sure the function has a clear header as to what inputs the function assumes, what outputs it produces and when it was written.

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!