Computers and Technology

Write a JAVA program called SavitskyGolayFilterTest to implement this method using a test data set, which by design has perfectly smooth behavior. We will
subsequently apply this method to the analysis of real-world data.
Generate the test data set using this differentiable analytic function:
y = 12(x/150)^2 - 5e^(-((x-400)/20)^2)
It can be seen that this is the sum of a parabola and a Gaussian, for which an analytic
derivative can easily be found for comparison with the output of your program.
Generate an 800 point test data set and save it in a file called ParabolaPlusGaussian. txt.
One way to do this is to enter the function into Excel, then copy and paste 800 data
points corresponding to x = 0 to 799 into your .txt file. Your program can be hardcoded
to take in this .txt file without any user input.
Use Drawing Panel to display your results. Use an 800 x 400 panel, corresponding to
0 <= x <= 799 and 0 <= y <= 399. With the origin of your graph at (0,399), your plot
should fill the Drawing Panel nicely. Suggestion: for data point symbols, use drawOval
with a width and height of 1.
Savitzky-Golay convolution coefficients, appropriate for least-squares smoothing or
differentiation of evenly spaced digital data over a finite window, are shown below.
There are 12 different sets of coefficients, the largest of which contain 9 coefficients.
Load these coefficients into a 12 x 9 2-D array, padding the 3-, 5-, and 7-coefficient
sets with leading and trailing zeros as necessary to bring the coefficient count to 9 for
all sets. Your program should allow the user to choose any one of these sets by entering
a row index from 0 to 11. In the follow-up exercise using real data, we will emphasize
filter 8 (see also note below).
Coefficients for smoothing (not needed for test data)
quadratic or cubic
0 {-3,12,17,12,-3}
1 {-2,3,6,7,6,3,-2}
2 {-21,14,39,54,59,54,39,14,-21}
quartic or quintic
3 {5,-30,75,131,75,-30,5}
4 {15,-55,30,135,179,135,30,-55,15} Coefficients for 1st derivative
linear or quadratic
5 {-1,0,1}
6 {-2,-1,0,1,2}
7 {-3,-2,-1,0,1,2,3}
8 {-4,-3,-2,-1,0,1,2,3,4}
cubic or quartic
9 {1,-8,0,8,-1}
10 {22,-67,-58,0,58,67,-22}
11 {86,-142,-193,-126,0,126,193,142,-8 6}
Provide the user with a prompt to help select the desired set. You are welcome to use
this code, which includes zero padding, for the user prompt:

// provide user prompts to specify Savitsky-Golay coefficients
System. out. println("select Savitsky-Golay filter: ");
System. out. println("smoothing");
System. out. println(" quadratic or cubic");
System. out. println(" 0 { 0, 0,-3,12,17,12,-3, 0, 0}");
System. out. println(" 1 { 0,-2, 3, 6, 7, 6, 3,-2, 0}");
System. out. println(" 2 {-21,14,39,54,59,54,39,14,-21}"); System. out. println(" quartic or quintic");
System. out. println(" 3 { 0, 5,-30, 75,131, 75,-30, 5, 0}");
System. out. println(" 4 {15,-55, 30,135,179,135, 30,-55,15}");
System. out. println();
System. out. println("1st derivative");
System. out. println(" linear or quadratic");
System. out. println(" 5 { 0, 0, 0,-1,0,1,0,0,0}");
System. out. println(" 6 { 0, 0,-2,-1,0,1,2,0,0}");
System. out. println(" 7 { 0,-3,-2,-1,0,1,2,3,0}");
System. out. println(" 8 {-4,-3,-2,-1,0,1,2,3,4}");
System. out. println(" cubic or quartic");
System. out. println(" 9 { 0, 0, 1, -8,0, 8, -1, 0, 0}");
System. out. println(" 10 { 0, 22, -67, -58,0, 58, 67,-22, 0}");
System. out. println(" 11 {86,-142,-193,-126,0,126,193,142,-8 6}");
// select filter
System. out. print("Enter an integer 0 - 11 corresponding to desired filter: ");
int filterKey = console. nextInt();
System. out. println();

To avoid array-out-of-bounds complications at the beginning and end of your data,
filter your data starting at x = 5 and ending at 794.
For filter 8, scale your differentiated data by a factor of 4 so it can be visualized
on the same Drawing Panel plot, i. e. your end result should contain two curves: the
original data and its scaled first derivative.
Anticipating analysis of real-world data, assume that the horizontal axis is time,
that each unit in x represents one month, and that the first data point corresponds
to March 1958. Provide tick marks every two years starting in 1960, which should
result in the last tick mark corresponding to 2024.

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 17:30, uh8hardiek
Ou listened to a song on your computer. did you use hardware or software?
Answers: 2
image
Computers and Technology, 23.06.2019 02:30, reyne36
Rafael needs to add a title row to a table that he has inserted in word. what should he do? use the alignment options. use the merge and center option for all the cells in the top row. use the merge and center option on the first two cells in the top row. none of the above
Answers: 3
image
Computers and Technology, 23.06.2019 17:30, Annlee23
When making changes to optimize part of a processor, it is often the case that speeding up one type of instruction comes at the cost of slowing down something else. for example, if we put in a complicated fast floating-point unit, that takes space, and something might have to be moved farther away from the middle to accommodate it, adding an extra cycle in delay to reach that unit. the basic amdahl's law equation does not take into account this trade-off. a. if the new fast floating-point unit speeds up floating-point operations by, on average, 2ă—, and floating-point operations take 20% of the original program's execution time, what is the overall speedup (ignoring the penalty to any other instructions)? b. now assume that speeding up the floating-point unit slowed down data cache accesses, resulting in a 1.5ă— slowdown (or 2/3 speedup). data cache accesses consume 10% of the execution time. what is the overall speedup now? c. after implementing the new floating-point operations, what percentage of execution time is spent on floating-point operations? what percentage is spent on data cache accesses?
Answers: 2
image
Computers and Technology, 24.06.2019 03:30, ava1018
The footer area of a web page generally houses which website feature? terms of use web page content business name or title menu headings
Answers: 1
Do you know the correct answer?
Write a JAVA program called SavitskyGolayFilterTest to implement this method using a test data set...

Questions in other subjects:

Konu
Mathematics, 14.10.2019 09:30