Question: need help in 3 hours help asap please ily mwah In Prablem 2, we ask you to write two function. The first is a generic
In Prablem 2, we ask you to write two function. The first is a generic stencil function, and the second is a function that generates bor filters that, when combined, will let you perform a specific operation known as conuolunion (Explained later in the section). Stencils A stenail (in the most general sense) is a way of computing a value for a given data point by uning the values of neighboring data points. Suppose we have a stencil function, f,+ is a function that accepts a list ot some fired length (for our puposes, let's say 3) and outputs a single value that is some combination of the valoes in than list. Here is one example def f(L} return []{1]+1[2] Applying a stencil function means tresting the stencil function like a "window" and "sliding" it across a list computing the result of the stencil function at each point. So if I start with the following liat: [a,b,c,d,c,t,c] Applying the stenoil function produces the following output list: [f([a,b,c]),f([b,c,d1),f([c,d,=]),f(td,t,f]),f([c,f,c])] 3:26 AM Testing If your code works, and you run the test code provided in problend.py . you should get the following output: [2.0,5.9,2.9,3.666066606660665,2.333333333335,5.0,23,0,25.4,27.0][265,245,357,501,677,245,1165][3,0,6.6,7,6,2.0,11.0,12.0,3.4,3.0] (The floating point numbers may be rounded a little bit differently, depending on exactly how you inplement your box filter, ) Testing If your code works, and you run the test code provided in preblem.py ; you should get the following gutput: [3,7,11,25,17,17,23,27,31,35,391 [1,3,7,21,21,21,29,23,27,31,25] [4,0,4,8,24,24,16,20,24,28,32] 2 [4,2,4,8,24,24,16,20,24,28,32] 5 [1,3,7,11,21,21,19,23,27,31,35] repeat o tines: 5 repeat 1 tine: 10 repeat 2 tinen 20 repeat 3 tines: 40 Testing If your code works, and you run the test code provided in problem2,py, you should get the following output: [3.,5.,1.,3.6666666666666665,2.3333333333333335,5.,13.,15.,17.][165,245,357,501,677,885,1165][3.,5.,0.9999999999999996,3.666666666666667,2.3333333333333335,5.,13.,14.9999999999999998,17.][3.,6.,7.,2.,11.,12.,3.,3.] (The floating point numbers may be rounded a little bit differently, depending on exactly how you implement your box filter.) Testing If your code works, and you run the test code provided in problem1.py, you should get the following output: [3,7,11,15,17,17,23,27,31,35,39] [1,3,7,11,21,21,19,23,27,31,35] [4,0,4,8,24,24,16,20,24,28,32] 2 [4,0,4,8,24,24,16,20,24,28,32] 5 [1,3,7,11,21,21,19,23,27,31,35] repeat 0 times: 5 repeat 1 time: 10 repeat 2 times: 20 repeat 3 times: 40
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
