Brute Force data-to-data fitting

This is small collection of Matlab scripts designed to extract the phase and amplitude difference from two data sets by performing brute-force fitting. It has been developed specifically to operate on second order correlation data from our Quantum Feedback in Cavity QED experiment.

News
Authors
Description
License
Download
How to use


NEWS:

[2013-02-17] Modifications have been made so that the peak estimation works more reliably and automatically for different oscillation frequencies.

[2013-01-11] Our paper using this software has been published in the New Journal of Physics: 10.1088/1367-2630/15/1/013017, for more info see publication list.

AUTHORS:

The scripts have been developed by Andres D. Cimmarusti and Burkley Patterson. The original idea came out of discussions with Howard J. Carmichael and Luis A. Orozco.

DESCRIPTION:

g2scaler_brute is a fitting routine designed to extract the phase and amplitude difference from two data sets. It is specifically designed to operate on second order correlation data from our Quantum Feedback in Cavity QED experiment.

It achieves this by fixing the scale of a target data vector (in this case, the left half of the g2), and transforming a fitting vector (pulsed, right half of g2) until they are optimally matched in a least-squares sense.

The program performs optimization according to the following procedure. It originally also performed horizontal scaling, but early results indicated that a frequency shift was not present.

The program imports the specified data and performs pre-processing. It separates the left and right halves of the data, the left being the "un-pulsed" target and the right being the data to transform to fit. It identifies the region of interest after a pulse and isolates the range in both sets of data. The corresponding errors in the data are stored alongside the target and fit data.

Using a custom function called centerdata, the program removes the best quadratic trend from the transformed data and centers it vertically about zero. This isolates the fitting from stray experimental effects independent of amplitude and phase. The errors are propagated to reflect the operation. This routine uses custom functions called polyfitweighted and polyvalweighted. Polyfitweighted performs error-weighted polynomial fits and returns fitting parameters with propagated errors. Polyvalweighted generates a vector of y values and y errors from the fit object returned by Polyfitweighted. The syntax is documented in the code.

An external loop iterates over all possible horizontal translations by shifting the elements of the transformed. A nested loop iterates over all possible vertical scales. Every iteration the sum of squared differences is computed and saved.

At each iteration of this brute-force search, errors are propagated and stored to reflect each transformation.

When the looping is complete the program searches the results of every transformation for the smallest difference and stores the corresponding xshift-yscale parameters.

To find the error in the parameters we extracted via brute force, we perform a chi squared analysis individually on each. Using a custom function called chi2diff, we evaluate the chi^2 goodness-of-fit in the neighborhood of the optimal parameter. This yields a parabola that can be easily fit. The sharpness of the parabola corresponds to the parameter error bounds, and the location of the minima corresponds to the optimal value of the parameter. This optimal value is very near what is found via brute force, and serves as both a refinement and a good consistency check.

If more than one data file is supplied to the program, then it will perform the procedure for each and store the results separately. This enabled us to easily analyze the effect of different pulse configurations on the amplitude and phase of quantum beats.

LICENSE:

This program is released under the terms of the GNU Public License v3 (GPLv3). For more information please see:

http://www.gnu.org/licenses/gpl-3.0.html

DOWNLOAD:

Source can be obtained from my github here.

HOW TO USE:

To run, simply open the script in Matlab, change the appropriate location of the data and datafile numbers and execute.