Physics 6730 Assignment 6

For each of the following exercises create the specified files with your answer(s). Submit your homework using the course submit utility.


Exercise 1 Simple awk scripts

In order to do wavelet filtering on a wave form, we need to set to some of the wavelet transform components to zero. Read the introduction to the awk utility in the Computer Lab Manual and write an awk script fltdbn.awk that takes a wavelet transform with one amplitude per line and zeros out all components from MIN to MAX, but leaves the others unchanged. The command
    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.


Exercise 2 Wavelet filtering

In the directory ~p6730/examples/a06 you will find the same code wavelet that you used in the lab exercises. There is no programming in this exercise. Instead, you are to use this program and your awk script from Exercise 1 to process the same Fly's Eye pulse that we filtered using Fourier transforms.

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:

  1. Strip the clock readings
  2. Do the daubn 4 wavelet transform
  3. Remove all detail from min on, where min is some integer power of 2 plus 1.
  4. Do the inverse wavelet transform
  5. Plot the result. (If you use gnuplot, redirect the final standard output to a file for plotting. Otherwise, use axis and xplot.)
Please copy your favorite sample Unix command to the answer file. Do not copy the output waveform, however.

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.


Exercise 3 Quadratic least squares

In this and the next exercise you are asked to produce and run code for fitting a quadratic to a set of data. The fitting equation is
    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.


Exercise 4 Fitting the pion mass

The file ~p6730/examples/a06/pion contains a table of results from a numerical simulation aimed at determining the dependence of the mass of the pion (an elementary particle) on the masses of the quarks which make it up. There are six numbers in the table, but we are concerned only with the first three. These give a parameter kappa, the pion mass mpi and the error (standard deviation) in the pion mass dmpi. (It so happens that 1/kappa is a linear function of the quark mass.) We want to fit the masses to the formula
    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.


This page is maintained by:
Carleton DeTar Mail Form
Last modified 22 February 2004