Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Question:

def sma(list1,n):

"""Returns simple moving average of a list of numbers in size n"""

count = 0

result = [0]*(len(list1)-n+1)

for item in range(len(result)):

result[count] = arithmetic_mean(list1[count:count+n])

count += 1

print count

return result

why is this code not working? (python)  I dont think the for loop is going through because counter never goes off 1.

For example, sma([5, 2, 8, 3, 7, 4], 3) should return [5, 4.3333333, 6, 4.666667], which consists of four averages: (5+2+8)/3, (2+8+3)/3, (8+3+7)/3, and (3+7+4)/3. Note that if the length of the input list is less than or equal to n, then the result list contains just one number, the list's mean.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91641169

Have any Question?


Related Questions in Computer Engineering

With regards to data mining business analytics why is it

With regards to data mining/ business analytics, Why is it not ideal to evaluate a classifier's performance on the training data set?

What is the difference between dekkers algorithm and igloo

What is the difference between Dekkers Algorithm and Igloo approach? Please provide examples that can explain this.

Please help with anbspfunctionnbspcodesymbol to convert

Please help with a function  codeSymbol , to convert each mark to a symbol (A, B, C, D, E, F) and a code (7,6,5,4,3,2,1) according to the table below. And call it in the main function. Use the table below to determine th ...

Question 1 suppose i need 10 bits to specify the offset

Question 1 : Suppose I need 10 bits to specify the offset within a page and 22 bits to specify the virtual page number and 18 bits to specify the physical page number. How big is a page in bytes? How big is the virtual m ...

Explain why a successful information security program is

Explain why a successful information security program is the shared responsibility of an organizations three communities of interest.

Discuss the importance functionality and role of a

Discuss the importance, functionality, and role of a GateKeeper or VoIP server in a VoIP -deployed network?

Clientserver model please respond to the followingimagine

"Client/Server Model" Please respond to the following: Imagine that you are a lead developer for social media company and that one of your responsibilities is to help mentor junior developers. The junior developer that y ...

The question is asking how to do it in linuxa scientist ran

The question is asking how to do it in Linux. A scientist ran an experiment that generated data that accumulated in a sequence of files: data1, data2, data3, data4 and data5. He wants to know how many lines of data he ha ...

Task 1create an array that holds a 20 random integers

Task 1: Create an Array that holds a 20 random integers between 1-50. Create an iterator that will return the memory address and value for each integer present in the Array. Task 2: Update Assignment 1 Task 2. Pass the v ...

List the common development failures and errors that

List the common development failures and errors that results from poor software security efforts

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As