Some correlation programs are due from previous sections: The first demonstrates that the AMDF (average magnitude difference function) of a good random number generator is very close to 33% of the random interval. Next, the starting phase of a sinewave immersed into 8 times as much noise is detected, often exactly, showing how powerful a technique correlation is. Lastly, the third listing attempts to calculate a correlation factor. Here is the original randomness section.
First, the AMDF program is not a rigorous test for randomness by a long shot: For one thing, it does not even check for uniform distribution of values within the random interval. Even as a 'fast' test, it can be improved: It is argued, in the randomness section, that correlation results are only needed for two phase differences, for a quick check. In its present form, the program provides the mean value of the AMDF, by performing calculations for every phase difference. The number of samples is, of course, adjustable.
In the second program, the code retrieves the initial phase of a sinewave on which 8 times as much noise has been superimposed, often exactly. This surely is a spectacular effect of correlation being such an efficient noise canceller. The number of samples has been increased from 256 to 360, but otherwise everything is as described in the original correlation section.
As the rms value of the functions involved can be anything, the result of the correlation integral is arbitrary, and not useful, unless normalised: The following expression looks appropriate:
Cmax(x,y,to)/[C(x,x,0)C(y,y,0)]0.5
where
C(x,y,to)=∫x(t)y(t-to)dt
For orthogonal functions, the value of this correlation factor is very nearly zero, but a result close to one implies the functions are a shifted scaled copy of each other. The formula is in all sorts of trouble if at least one of the functions involved has not got a mean value of zero (the code takes care of that.) Finally, this expression is not suitable for autocorrelation when the phase difference is zero, because then it will always yield a value of one, even for a random signal.
A pure and noisy sinewave are correlated in the program: The correlation factor lags behind the signal to noise ratio (does not drop equally fast.) This is no surprise, given the excellent noise rejection properties of correlation. All programs assume equally- spaced samples.
More links:
Random quotes:
She can't sing, she can't act, she looks terrible. Sign her immediately!