Simple Moving Average (SMA) in a sequence of numbers is a function that returns average of...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Simple Moving Average (SMA) in a sequence of numbers is a function that returns average of k data points back at every index of sequence. You may consider as you are calculating everyday average temperature for the last k days. For example, for the list [0, 1, -1, -2, -2] SMA of 2 points should return [None, 0.5, 0.0, 1.5, -2.0]. The first point is None because you dont have enough data to calculate back. Write a function named ama_2 to calculate moving average that takes input a list of numbers, returns a list numbers that includes SMA of 2 points. Note: Input and output should be of same length and first point in the output should be None. [23]: tmp [0, 1, -1, -2, -2] def sma_2(data): #Write the implementation pass 2 # Check if it works sma_2(tmp) Simple Moving Average (SMA) in a sequence of numbers is a function that returns average of k data points back at every index of sequence. You may consider as you are calculating everyday average temperature for the last k days. For example, for the list [0, 1, -1, -2, -2] SMA of 2 points should return [None, 0.5, 0.0, 1.5, -2.0]. The first point is None because you dont have enough data to calculate back. Write a function named ama_2 to calculate moving average that takes input a list of numbers, returns a list numbers that includes SMA of 2 points. Note: Input and output should be of same length and first point in the output should be None. [23]: tmp [0, 1, -1, -2, -2] def sma_2(data): #Write the implementation pass 2 # Check if it works sma_2(tmp)
Expert Answer:
Answer rating: 100% (QA)
Certainly Heres the implementation of the sma2 function in Python python ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
5. Planets have been observed orbiting a star in another solar system. Measurements are made of the orbital radius r and the time period T of each of these planets. The variation with R cubed of T...
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
How are direct and indirect materials costs distinguished?
-
A company manufactures four products from an input of a raw material to process 1. Following this process, product. A is processed in process 2, product B in process 3, product C in process 4 and...
-
Kristina is the accounting manager for a small, local firm that has full- and part-time staff. What must Kristina consider when classifying employees as exempt or nonexempt?
-
Compute payback and ARR with residual value (Learning Objective 2)} Refer to the Deer Valley Expansion Data Set. 1. Compute the average annual net cash inflow from the expansion. 2. Compute the...
-
During the year ended December 31, 20--, Choi Company completed the following transactions: Apr. 15 Declared a semiannual dividend of $1.50 per share on preferred stock and $0.40 per share on common...
-
On June 01, 2015 a company sold 6,000 $1,000 face value bonds at 105. The bonds is dated June 01, 2015 that would mature in 5 years and pay 12% interest semi-annually on June 1 & Dec. 31. The cost in...
-
Quantitative Problem: Sunshine Smoothies Company (SSC) manufactures and distributes smoothies. SSC is considering the development of a new line of high-protein energy smoothies. sSC's CFO has...
-
Any leftover acetylcholine still floating around in the synaptic cleft will either diffus away or get degraded by an enzyme called acetylcholase acetylcholinase acetylcholinesterase
-
The Long History of Anti-Latino Discrimination in America, you will complete a one-page reflection. Hint: Reflect on the injustices ranging from school segregation to mob violence and mass...
-
Riverdale manufactured ladies apparel. Charges to work in process account show: Direct materials used 341,000 Direct labor costs 324,500 Factory overhead 259,600 At the end of the period, two orders...
-
What are the psychological mechanisms underlying employee motivation and commitment, and how can organizations effectively leverage intrinsic and extrinsic rewards to enhance performance and job...
-
For the writing assignment, we must write about a subject or subjects that we learned this semester and how we believe this subject/subjects will help in our chosen career path. My subject is: Types...
-
Expandit Corporation is evaluating a proposed project that requires an initial outlay of $2,000,000. It is estimated that the after-tax cash inflows from the project will be $210,000 annually in...
-
Required Information [The following Information applies to the questions displayed below.] Bunnell Corporation is a manufacturer that uses job-order costing. On January 1, the company's Inventory...
-
What is the order p of a B + -tree? Describe the structure of both internal and leaf nodes of a B + -tree.
-
Consider the following continuous-time signal 1-t 0st <1 x(t) = otherwise
-
Let ¤ t ¤ 1 ¤ t ¤ 1, and zero otherwise, be the input to a 2 bit analog-to-digital converter. (a) For a sampling period T s = 0.025 sec. determine and plot using MATLAB...
-
We wish to design a discrete Butterworth filter that can be used in filtering a continuous-time signal. The frequency components of interest in this signal are between 0and 1 kHz, so we would like...
-
Interpret favorable variance (Learning Objective 5) Exhibit 10-20 shows that the Mexican sauces product line had a favorable marketing expense variance. Does this favorable variance necessarily mean...
-
Prepare inventory, purchases, and cost of goods sold budget (Learning Objective 2) Leno sells tire rims. Its sales budget for the nine months ended September 30 follows: In the past, cost of goods...
-
Prepare summary performance report (Learning Objective 1) Hanna White owns a chain of travel goods stores. Last year, her sales staff sold 10,000 suitcases at an average sales price of $150. Variable...
Study smarter with the SolutionInn App