Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Just need the code for the class SlidingWindowAveragerator and please use the same parameters. It needs to pass all tests. Question 1: Sliding Window Averagerator

image text in transcribed

image text in transcribed

Just need the code for the class SlidingWindowAveragerator and please use the same parameters. It needs to pass all tests.

Question 1: Sliding Window Averagerator Complete the code below, defining a sliding window averagerator. The class should have methods: _init__(self, window_size) to initialize, add(self, x), to add a value as well as properties avg and std, as in the previous averagerator classes. 1 ### Question 1: Implement a "slidingWindowAveragerator 2 3 class SlidingwindowAveragerator(object): 4 5 ### YOUR CODE HERE w 6 1 ### 5 points: Tests for SlidingWindowAveragerator 2 3 # First some simple cases. 4 sa = SlidingWindowAveragerator (20) 5 for in range (10): 6 sa. add (10) 7 assert sa. avg == 10 8 assert sa.std == 0 9 10 sa = SlidingWindowAveragerator (10) 11 for _in range(10): 12 sa.add(4) 13 assert sa.avg == 4 14 for in range(10): 15 sa.add(8) 16 assert sa.avg == 8 17 assert sa.std = 0 18 19 N 1 ### 10 points: Now for slightly more complex tests. 2 3 sa = SlidingWindowAveragerator(10) 4 for i in range(10) 5 sa.add(i) 6 assert sa. avg 4.5 7 assert abs(sa.std - 2.87)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 2012 Proceedings Part 2 Lnai 7197

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284892, 978-3642284892

More Books

Students also viewed these Databases questions

Question

Define ANN.

Answered: 1 week ago

Question

How would you describe your typical day at work?

Answered: 1 week ago