In the provided A1Q1. java file, complete the rollingAverage () method. This method will compute the rolling average of some data using a specified width (number of data points used for the average). This method takes an array of floating point numbers (called data) and an integer (called width) as input. The method returns a new array that is the same size as the input array and will contain thc rolling average of the innut array data using vidth data oints for cach valuc

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

please answer question in java, thanks

In the provided A1Q1. java file, complete the rollingAverage() method. This method will
compute the rolling average of some data using a specificd width (number of data points uscd for
the average). This method takcs an array of floating point numbers (called data) and an integer
(called width) as input. The method returns a new array that is the same size as the input array
and will contain the rolling average of the input array data using width data points for cach value.
public static double] rollingAverage (double [] data, int width)
For cach position where there is not cenough data points (width) to compute the average, you
will use the NaN (Not-A-Number) value. In particular, the first width-1 clements of the output
array should have this value. Here are some cxamples:
A1Q1.rollingAverage (new double[]{1,2,4}, 1) -> [1.0, 2.0, 4.0]
A1Q1.rollingAverage (new double []{1,2}, 2) -> [NaN, 1.5]
A1Q1.rollingAverage (new double []{1,2,4,9}, 3) -> [NaN, NaN, 2.3333333333333335, 5.0]
A1Q1.rollingAverage (new double[0{1,2,4}, 4) -> [NaN, NaN,
NaN]
You will need to investigate and use Java's Double class to learn more about the value NaN.
In future assignments, restrictions on the input arguments passed to methods you create will be
provided as preconditions for the methods. For this assignment, they are listed here (as well as in
the provided java file). Note that no testing will involve input data that violates these restrictions.
data: 0 <= data.length <= Integer.MAX_VALUE/100
size: 1 <= width <= Integer. MAX_VALUE
Transcribed Image Text:In the provided A1Q1. java file, complete the rollingAverage() method. This method will compute the rolling average of some data using a specificd width (number of data points uscd for the average). This method takcs an array of floating point numbers (called data) and an integer (called width) as input. The method returns a new array that is the same size as the input array and will contain the rolling average of the input array data using width data points for cach value. public static double] rollingAverage (double [] data, int width) For cach position where there is not cenough data points (width) to compute the average, you will use the NaN (Not-A-Number) value. In particular, the first width-1 clements of the output array should have this value. Here are some cxamples: A1Q1.rollingAverage (new double[]{1,2,4}, 1) -> [1.0, 2.0, 4.0] A1Q1.rollingAverage (new double []{1,2}, 2) -> [NaN, 1.5] A1Q1.rollingAverage (new double []{1,2,4,9}, 3) -> [NaN, NaN, 2.3333333333333335, 5.0] A1Q1.rollingAverage (new double[0{1,2,4}, 4) -> [NaN, NaN, NaN] You will need to investigate and use Java's Double class to learn more about the value NaN. In future assignments, restrictions on the input arguments passed to methods you create will be provided as preconditions for the methods. For this assignment, they are listed here (as well as in the provided java file). Note that no testing will involve input data that violates these restrictions. data: 0 <= data.length <= Integer.MAX_VALUE/100 size: 1 <= width <= Integer. MAX_VALUE
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY