For each of the following exercises create the specified files with your answer(s). Submit your homework using the course submit utility.
awk -f fltdbn.awk -v MIN=17 -v MAX=32 wvltxfm
should zero out components on lines 17 to 32 in the wavelet transform
file wvltxfm.
Hand in your script file.
The answer file to be submitted is wavelet.txt.
Both the code and your awk script read data from standard input and write to standard output. Thus it is possible to use pipes to chain the processes.
Here is the usage for wavelet:
wavelet <xfmtype> [nxfm] <isign = +/-1>where xfmtype specifies the transform type and is either haar, daub4 or daubn, [nxfm] is needed only for daubn and specifies the order of the Daubechies transform (4,12,20), and isign is +1 for the transform and -1 for the inverse transform. The program takes a waveform or transform on standard input and writes the transform or waveform to standard output. If the number of data points on standard input is not an integer power of 2, it is padded with trailing zeros to make it so.
In the following example, we do a (forward) daub4 transform of the waveform in pulse:
wavelet daub4 +1 < pulse
The file ~p6730/examples/a05/pulse1 was used in Assignment 5 to illustrate the use of Fourier transforms for data filtering. Notice that the data file gives a clock reading as well as a signal value. The wavelet programs here want only a signal. You will need to use awk to strip the clock reading.
On a single Unix command line using pipes do the following:
Do this exercise for both the n = 4 and n = 12 Daubechies transforms. Explore choices of the filter constant min, and find a value that approximates the appearance of Fourier transform low-pass filtering with tau = 0.1. What value of min gives a reasonable approximation? Which value of n (4 or 12) gives a reasonable approximation to the Fourier transform filtering process, or does it matter? Can the wavelet transform produce a negative signal value when the original signal is entirely positive? Can the low-pass Fourier transform filter do that? Put your answers in the answer file.
y = a x2 + m x + b.
(To assist in comparison with a linear fit, we have retained the
linear equation notation for m and b.) Please refer to
the notes on
curve fitting . You will observe that this fitting problem is
linear in the fit parameters.
In the first part of this exercise, you are asked to derive (by hand) the elements of the the vector c and matrix M, as described in the handout. The matrix and vector define the linear system, whose solution is a vector of the best fit parameters. The general expressions are given in Eqs (36) and (37) of the handout. The particular application to the linear fit is given in Eqs (9) and (10). Please use a similar notation for the quadratic fit. For uniformity in labeling rows and columns, let's adopt the convention that the fit parameter a comes first, m next, and b last. Please put your results in the file quadrfit.txt to hand in.
In ~p6730/examples/a06/linearfit.cc you will find a modified version of the linear fitting code we looked at last semester. While it may be less efficient in storage and execution, it should be easier to modify. Your task here is to modify it to create a new code quadrfit that does a quadratic fit. There is also a makefile. You should modify it so it compiles your new code as well as linearfit. Here are the parts of the code you should provide:
| File | Purpose of procedure |
|---|---|
| quadrfit.cc | Main program. (hand in) |
| Makefile | Rule for compiling the above. (hand in) |
The input format and output format should be the same as in linearfit, except that one more best fit parameter should be reported. Please note that linearfit.cc calls routines in linalg.cc, which you will find in ~p6730/lib. The corresponding header linalg.h is in ~p6730/include. Your Makefile file should grab these in the same manner as nr.h in previous exercises. The object file linalg.o is already compiled and located in ~p6730/lib. Simply list this file along with your other object files when building your code.
mpi2 = a/kappa2 + m/kappa + b.
and in the process, see whether the quadratic term is needed.
You may have worried that this formula does not appear to be compatible with the quadratic equation above. However, one merely needs to convert the data so that the x value is 1/kappa, the y value is mpi2, and the error in the squared mass is 2*mpi*dmpi. You should transform the data file into the appropriate input format using an awk command.
Run your program with the transformed data. To check your results, you may want to compare plots of the best fit curve and the data points. Put your best fit results with errors and chi square values in the file pion.txt to be handed in. Determine the goodness of fit and put the result in the same file. The command we used last semester was
~p6720/bin/conf_level x2 df
Then run the linearfit code with the same data to see the effect of omitting the quadratic term. Include your results and conclusions in the same answer file.