output of mlab cohere_pairs vs. cohere

I need to compute coherence between a bunch of different signals, for a bunch of different trials, and it seems like cohere_pairs() is exactly what I should use. However, I’m a little confused about the output. If I use cohere() to produce the coherence values for two signals, I get an array of coherence values, one for each frequency in the frequency array. However, if I use cohere_pairs() with just that pair specified, I get the same frequency array but a single value for that pair. See the example output below:

X = np.random.rand(1024,2)

c, f = mpl.mlab.cohere(X[:,0], X[:,1])

c.shape, f.shape

((129,), (129,))

c, p, f = mpl.mlab.cohere_pairs(X, [(0,1)])

f.shape

(129,)

c

0.67176286373547267

From reading the doc strings I was under the impression that the value ‘c[(i,j)]’ (output from cohere_pairs) should be the same output you would get from running ‘cohere(X[:,i], X[:,j])’. Is this a bug, or am I missing something?

Thanks,

-Barrett

···


Barrett Heyneman
PhD Student
Stanford University
Mechanical Engineering, Design Division