Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question

Need help with this Java problem: Note: Please only use these classes/methods to solve the problem: Math, String, StringBuilder, Double (or anyprimitive wrapper class), any helper class you create yourself

Transcribed Image Text:// 1 peak in the data double [] = {1.1, 2.2, 3.1, 4.2, 2.3}; double ] [] peaksi = A1Q2.peaks (data1, 0.0001); == { {4.2}, {3.0} } datal // assert: peaks1 // 2 peaks in the data = {1.1, 2.2, 1.1, 2.2, 3.3}; A1Q2. peaks (data2, 0.00001); == { {2.2, 3.3}, (1.0, 4.0} } double [] data2 double [) 0 peaka2 // assert: peaks2 // NO peaks int the data double [] data3 = {0.3, 1.1, 2.2, 2.2, 2.2, 1.1, 0.2}; double[] [] peaks3 = A1Q2.peaks (data3, 0.00001); // assert: peaka3 { 0, 0 } =3D Note that we are not considering what might be described as plateaus in the data. A plateau occurs when a local maximum value is repeated one or more times consecutively (the dataset data3 from above has a plateau with value 2.2 that spans index values 2-4, inclusive).
[画像:When analyzing data, such as the output of the rolling average method from the previous problem, it is sometimes useful to identify where the (local) maximum valucs are located. We'll call these max- imal values peaks in the data. More formally, if we have a sequence of numbers do, d1, d2, ..., dn-1, the peaks are identified as follows: 1. do is a peak if do > dı, 2. dn-1 is a peak if d,-2 < d,-1, 3. for any 1<i<n- 2, d; is a peak if d;-1 < d; and d; > di+1 In the provided A1Q2.java file, you will complete the peaks () method which finds all peak values (and their positions) in a given array of numbers. public static double[] [] peaks (double [] data, double epsilon) The input parameter data stores the data that we are looking for peaks in and epsilon is uscd as a tolerance value for floating point mumber equality. Because of the representational crror of floating point mumbers, we should never try to check if two floating point mımbers are the samc. Instcad, we consider two floating point numbers to be the same mumber if they are close enough to cach other. In particular, two numbers r and y are considered equal if and only if |r – y| < epsilon. While not necessary, it is highly recommended that you create and use a static helper function (in the same A1Q2 class) to determine if two floating point numbers are considered equal for a given epsilon. You must not use equals (), compareTo () or compare () from the Double class for this. The method returns an array containing exactly two (2) arrays of doubles. The first array holds all the peak values and the second array holds the index positions of those pcaks. For example, ]
expand button
Transcribed Image Text:When analyzing data, such as the output of the rolling average method from the previous problem, it is sometimes useful to identify where the (local) maximum valucs are located. We'll call these max- imal values peaks in the data. More formally, if we have a sequence of numbers do, d1, d2, ..., dn-1, the peaks are identified as follows: 1. do is a peak if do > dı, 2. dn-1 is a peak if d,-2 < d,-1, 3. for any 1<i<n- 2, d; is a peak if d;-1 < d; and d; > di+1 In the provided A1Q2.java file, you will complete the peaks () method which finds all peak values (and their positions) in a given array of numbers. public static double[] [] peaks (double [] data, double epsilon) The input parameter data stores the data that we are looking for peaks in and epsilon is uscd as a tolerance value for floating point mumber equality. Because of the representational crror of floating point mumbers, we should never try to check if two floating point mımbers are the samc. Instcad, we consider two floating point numbers to be the same mumber if they are close enough to cach other. In particular, two numbers r and y are considered equal if and only if |r – y| < epsilon. While not necessary, it is highly recommended that you create and use a static helper function (in the same A1Q2 class) to determine if two floating point numbers are considered equal for a given epsilon. You must not use equals (), compareTo () or compare () from the Double class for this. The method returns an array containing exactly two (2) arrays of doubles. The first array holds all the peak values and the second array holds the index positions of those pcaks. For example,
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
    Recommended textbooks for you
    Text book image
    Computer Networking: A Top-Down Approach (7th Edi...
    Computer Engineering
    ISBN:9780133594140
    Author:James Kurose, Keith Ross
    Publisher:PEARSON
    Text book image
    Computer Organization and Design MIPS Edition, Fi...
    Computer Engineering
    ISBN:9780124077263
    Author:David A. Patterson, John L. Hennessy
    Publisher:Elsevier Science
    Text book image
    Network+ Guide to Networks (MindTap Course List)
    Computer Engineering
    ISBN:9781337569330
    Author:Jill West, Tamara Dean, Jean Andrews
    Publisher:Cengage Learning
    Text book image
    Concepts of Database Management
    Computer Engineering
    ISBN:9781337093422
    Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
    Publisher:Cengage Learning
    Text book image
    Prelude to Programming
    Computer Engineering
    ISBN:9780133750423
    Author:VENIT, Stewart
    Publisher:Pearson Education
    Text book image
    Sc Business Data Communications and Networking, T...
    Computer Engineering
    ISBN:9781119368830
    Author:FITZGERALD
    Publisher:WILEY