1
$\begingroup$

In Statistica gain is defined as follows:

Gain. The gain value is computed by dividing the cross-amplitude value by the spectrum density estimates for one of the two series in the analysis. Consequently, two gain values are computed, which can be interpreted as the standard least squares regression coefficients for the respective frequencies.

However, spec.pgram (the engine behind spectrum) in R does not return the cross-amplitude value (as far as I can tell). How can I calculate gain for these signals?

Example:

makewave <- function(freq,phase,amp,Nsamples=length*samplerate,samplerate,time=Nsamples/samplerate,as.time.series=TRUE) {
  time <- Nsamples/samplerate
  phase <- phase*(2*pi)/180
  wavetimes <- seq(0+phase,time*freq*pi*2+phase,length.out=Nsamples)
  #plot(1:samples/samplerate,amp*sin(wavetimes),type="l",xlab="Time")
  if (as.time.series) {res <- ts(amp*sin(wavetimes),deltat=1/samplerate)} else {res <- amp*sin(wavetimes)}
  return(res)
}
signal1 <- makewave(15,30,1,180,60)
signal2 <- makewave(15.01,60,1,180,60)
signal.union <- ts.union(signal1,signal2)
sp <- spectrum(signal.union,span=c(3),taper=0)
plot(sp)
plot(sp,plot.type="phase")
plot(sp,plot.type="coh")
$\endgroup$
  • $\begingroup$ I'm sorry if this question is too simple for this site. If so, I'll delete it. $\endgroup$ – russellpierce Apr 3 '12 at 22:04
  • 1
    $\begingroup$ It's not too simple, it's just not very clear- at least to me. What do you mean by "bivariate fft"? It looks like you are calculating the fft of two signals added together. Is that what "bivariate fft" means? What does "cross-amplitude value" mean? $\endgroup$ – Jim Clay Apr 4 '12 at 1:10
  • 1
    $\begingroup$ @JimClay I believe that bivariate FFT is simply a two-dimensional FFT. $\endgroup$ – Phonon Apr 4 '12 at 1:44
  • $\begingroup$ "The cross amplitude values are computed as the square root of the sum of the squared cross-density and quad-density values. The cross-amplitude can be interpreted as a measure of covariance between the respective frequency components in the two series." (documentation.statsoft.com/STATISTICAHelp.aspx?path=TimeSeries/…) $\endgroup$ – Jim Clay Apr 4 '12 at 13:33
  • $\begingroup$ I am/was shaky on the correct terminology. I have two signals, and I want to compare them to see how much the 2nd matches the first (coh), how much the 2nd lags behind the 1st (phase), and the extent to which the 2nd is under/overshooting the peak amplitudes of the 1st. $\endgroup$ – russellpierce Apr 4 '12 at 15:55
1
$\begingroup$

I am/was shaky on the correct terminology. I have two signals, and I want to compare them to see how much the 2nd matches the first (coh), how much the 2nd lags behind the 1st (phase)

Normalized cross-correlations are good at that. I don't know what the relevant command would be in Statistica, but in Matlab you would use the command xcorr.

and the extent to which the 2nd is under/overshooting the peak amplitudes of the 1st.

To answer that in a useful way it would help a great deal to see the signals that you are talking about. Are you just interested in the peaks, or the signal in general? If you are talking about the signal in general then you could time-align the signals using the information from your cross-correlation, and then divide one of the signals by the other. If you are just interested in the peaks you could do the same and then just extract the results at the peak locations.

$\endgroup$
  • $\begingroup$ I am interested in the power in each FFT bin in relation to the power in the other bin. Statistica reports some kind of ratio here as "gain", but I am not sure how it is calculated. I'll provide sample data later today. $\endgroup$ – russellpierce Apr 12 '12 at 16:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.