| T O P I C R E V I E W |
| jonni |
Posted - 10/15/2003 : 05:57:47 AM Hi,
I have a large number of XY datasets. In my analysis I autocorrelate the Y column (correlate Y with itself using Menu id=32904; run.section(WKSANALY,Correlate);). This gives two new columns of row shift (X2) and the result of the correlation (Y2).
If you are familiar with autocorrelation the shape of the resulting curve is a sinc shaped function (like half a Gaussian with a decaying oscillatory tail). The useful parameter is the HWHM (half width at half maximum), i.e. the first instance that Y2 falls to half its peak value, which always occurs in the first row. The remainder of the curve, including any other instances the curve passes through half maximum is of no interest.
The question is: how do I find this value (HWHM) for many datasets using labtalk? I can imagine a loop which scans the data row by row, but I am interested in the exact Y2 value 0.5 (all correlation curves are normalised so that the maximum value is unity). Therefore if 0.5 does not occur some interpolation is needed. This is where my labtalk skills fail me!
The end result needs to be a new dataset tabulting the values of this parameter as a function of some variable that changes between datasets.
Any help would be most appreciated.
Many thanks.
jonni |
| 2 L A T E S T R E P L I E S (Newest First) |
| jonni |
Posted - 10/16/2003 : 05:11:55 AM Hi Edgar,
Thanks for your reply and interest.
You put me on the right track with your suggestion. It is X rather than Y you eventually need to find. In the following script (for anyone interested in the solution) the 'Lag' value is the interpolated result when col(E) (my normalised correlation data) is 0.5. (I know the step in the true X range so the subsequent transformation is trivial.)
%a=001 002 003 004 005 006 007 008 009 010; for (ii=1;ii<=10;ii+=1) { for (jj=2;jj<=a039s%[%a,#ii]!wks.maxrows;jj+=1) { if (a039s%[%a,#ii]_e[jj-1]>0.5 && a039s%[%a,#ii]_e[jj]<=0.5) { aa=(a039s%[%a,#ii]_lag[jj-1]-a039s%[%a,#ii]_lag[jj])/(a039s%[%a,#ii]_e[jj-1]-a039s%[%a,#ii]_e[jj]); data3_b[ii]=a039s%[%a,#ii]_lag[jj]+(0.5-a039s%[%a,#ii]_e[jj])*(aa); break; }; }; }
In the above the prefix to all my datasets is 'a039s' and the appended suffix (001,002,etc) defines the particular set, and is held in the string %a. Index 'ii' runs over all sets, and index 'jj' runs over all rows in the particular set (starting at the second as we know the first row contains the max value of unity). As mentioned col(E) holds the normalised correlation data and col(Lag) the shift in the X data. As Edgar suggested when the transition across 0.5 in col(E) is encountered the interpolated lag is tabulated in data3_b and we break out of the loop as we are not interested in further occurences.
Edgar, thanks again.
Best regards,
jonni |
| edgar.kaiser |
Posted - 10/15/2003 : 07:48:29 AM Hi Jonni,
so you scan your dataset until you find a value Y2[n] < 0.5 with associated X2[n]. n is the row index. In this case you have Y2[n-1] >= 0.5
Now for the interpolation: Y2(0.5) = Y2[n] + (0.5 - X2[n])*(Y2[n-1] - Y2[n])/(X2[n-1] - X2[n])
This is a linear interpolation. If you need a more precise interpolation you could do a NLF of your sinc model function.
Does this answer your question?
Best regards,
Edgar |
|
|