Question: Anwsering in python code on jupyternotebook Write a discrete convolution function myConv that convolves two arrays {fi,i=0,,Nf1} and {wj,j=0,,Nw1} to obtain an output time series

Anwsering in python code on jupyternotebook Write a discrete convolution function myConvAnwsering in python code on jupyternotebook

Write a discrete convolution function myConv that convolves two arrays {fi,i=0,,Nf1} and {wj,j=0,,Nw1} to obtain an output time series \{ gn}. For simplicity, assume a fixed sampling interval =1, and further, that f and w are 0 outside of their sampled regions. 1. How long is {gn} ? In other words, how many non-zero points can it have? Justify your answer. 2. Please copy and paste your function g=myconv(f,w) to the PDF report. 3. Provide a test to convince yourself (and me) that your function agrees with numpy. convolve . For example, generate two random timeseries f, w with Nf=75,Nw=150, drawing each element from U[0,1], and plot the difference between your function's output and numpy's. Include the code for your test in the PDF report. 4. Compare the speed of your myConv function to the NumPy function. Provide a plot of the comparison, and include your python code in the PDF report. Is your function faster or slower than the NumPy function? Can you suggest why that is the case? Hint: For the speed test part, make up your own fi and wj time series, and for simplicity, study the cases of Nf=Nw=10,100,1000,10000. To accurately time each computation of the convolution function, import the time module and place calls to time. time around your code: import time t1 = time. time 0 g= myConv (f,w) t2 = time. time 0 print ( t 2 -t 1) Alternatively, use the timeit module: import timeit print(timeit. timeit ('g = myConv(f, w)', number=10000))

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!