Time-varying signals: cross- and auto-correla5on, - - PowerPoint PPT Presentation
Time-varying signals: cross- and auto-correla5on, - - PowerPoint PPT Presentation
Time-varying signals: cross- and auto-correla5on, correlograms NEU 466M Instructor: Professor Ila R. Fiete Spring 2016 Sta5s5cal measures We
Sta5s5cal ¡measures ¡
- We ¡first ¡considered ¡simple ¡sta5s5cal ¡measures ¡
for ¡single ¡variables ¡(mean, ¡variance). ¡
- We ¡next ¡considered ¡measures ¡for ¡the ¡
rela5onship ¡between ¡two ¡(sta5onary) ¡random ¡ variables ¡(covariance, ¡Pearson’s ¡correla5on ¡ coefficient; ¡regression). ¡ ¡
- Extension ¡to ¡K ¡variables: ¡pairwise ¡rela5onships ¡
(covariance ¡matrix). ¡
- Now, ¡extension ¡to ¡5me-‑series: ¡rela5onships ¡
between ¡different ¡5me-‑varying ¡signals. ¡ ¡
Time-‑series ¡data ¡
g: ¡a ¡temporally ¡varying ¡signal ¡ ¡ sampled ¡at ¡discrete ¡intervals ¡ h: ¡another ¡5me-‑varying ¡signal, ¡ ¡ sampled ¡at ¡the ¡same ¡5mes ¡
How ¡many ¡variables? ¡In ¡g ¡alone? ¡ ¡
{· · · gt−1, gt, gt+1 · · · }
{· · · ht−1, ht, ht+1 · · · }
Time-‑series ¡data ¡
g: ¡a ¡temporally ¡varying ¡signal ¡ ¡ sampled ¡at ¡discrete ¡intervals ¡
- Time-‑series ¡not ¡sta5onary. ¡
¡
- Could ¡think ¡of ¡response ¡at ¡each ¡5me ¡point ¡as ¡separate ¡
(though ¡typically ¡not ¡independent) ¡variable. ¡
- If ¡length(g) ¡= ¡T, ¡then ¡T ¡variables ¡in ¡g. ¡ ¡
¡
- Same ¡5me-‑point ¡in ¡repe55ons ¡of ¡the ¡series ¡from ¡same ¡
ini5al ¡condi5on: ¡mul5ple ¡samples ¡of ¡that ¡variable. ¡
{· · · gt−1, gt, gt+1 · · · }
Finding ¡structure ¡between ¡5me-‑series ¡
g: ¡a ¡temporally ¡varying ¡signal ¡ ¡ sampled ¡at ¡discrete ¡intervals ¡ h: ¡another ¡5me-‑varying ¡signal, ¡ ¡ sampled ¡at ¡the ¡same ¡5mes ¡
How ¡about ¡trying ¡previously ¡seen ¡sta5s5cal ¡measures? ¡ ¡
{· · · gt−1, gt, gt+1 · · · }
{· · · ht−1, ht, ht+1 · · · }
compute cov(g, h)
100 200 300 400 500 600 700 800 900 1000 −1 −0.8 −0.6 −0.4 −0.2 0.2 0.4 0.6 0.8 1 time response
Example ¡of ¡two ¡5me-‑series ¡
C(g, h) = 0, hghi ⇡ 0
Correct ¡but ¡unsa5sfying: ¡ ¡g, ¡h ¡similarly ¡5me-‑varying ¡func5ons: ¡the ¡same ¡func5on ¡with ¡a ¡π/2 ¡shi[. ¡ ¡
dt = 0.001 t = [0 : dt : 1 − dt]; g = sin(20 ∗ pi ∗ t); h = cos(20 ∗ pi ∗ t); figure; hold on; plot(g); plot(h,0 r0); ylabel(0response0) xlabel(0time0)
Defini5on: ¡cross-‑correla5on ¡func5on ¡ Cg,h(n) =
∞
X
m=−∞
g∗(m)h(m + n) [· · · g∗
−3 g∗ −2 g∗ −1 g∗ 0 g∗ 1 g∗ 2 g∗ 3 · · · ]
[· · · h−3 h−2 h−1 h0 h1 h2 h3 · · · ]
take time-by-time product, add all terms
n = 0 :
Cg,h(n) =
∞
X
m=−∞
g∗(m)h(m + n) [· · · g∗
−3 g∗ −2 g∗ −1 g∗ 0 g∗ 1 g∗ 2 g∗ 3 · · · ]
[· · · h−2 h−1 h0 h1 h2 h3 h4 · · · ] h − tape shifted leftwards by 1
n = 1 :
Defini5on: ¡cross-‑correla5on ¡func5on ¡
Measure ¡of ¡relatedness ¡at ¡different ¡5me ¡shi[s ¡
Cg,h(n) =
∞
X
m=−∞
g∗(m)h(m + n)
- The ¡cross-‑correla5on ¡func5on ¡is ¡a ¡measure ¡of ¡covariance ¡
between ¡g, ¡h ¡at ¡different ¡rela5ve ¡5me-‑shi[s ¡(for ¡zero-‑ mean ¡or ¡mean-‑subtracted ¡signals). ¡ ¡ ¡ ¡
- How ¡is ¡g ¡at ¡any ¡5me ¡(linearly) ¡related ¡to ¡h ¡n ¡5me-‑steps ¡
away? ¡ ¡
Cross-‑correla5on ¡func5on ¡for ¡finite-‑length ¡signals ¡
Cg,h(n) =
N−n
X
m=1
g∗(m)h(m + n) {g1, · · · , gN} {h1, · · · , hN}
g, ¡h: ¡5me-‑series ¡of ¡length ¡N ¡
Total ¡length ¡of ¡cross-‑correla5on: ¡2N-‑1 ¡ Zero-‑shi[ed ¡entry: ¡N ¡
average ¡over ¡ ¡ (N-‑|n|) ¡terms ¡
¡
- ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡: ¡ ¡does ¡not ¡commute ¡(contrast ¡
with ¡covariance). ¡ ¡
- In ¡fact, ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡: ¡ ¡shi[ing ¡h ¡to ¡right ¡
rela5ve ¡to ¡g: ¡equivalent ¡to ¡shi[ing ¡g ¡to ¡le5 ¡rela5ve ¡ to ¡h. ¡(Same ¡plot, ¡flipped ¡5me ¡axis.) ¡ ¡
- Ordering ¡mabers: ¡tells ¡which ¡signal ¡leads ¡the ¡other. ¡ ¡
Proper5es ¡of ¡the ¡cross-‑correla5on ¡
Cgh(n) = Chg(−n) Cgh(n) 6= Chg(n)
100 200 300 400 500 600 700 800 900 1000 −1 −0.8 −0.6 −0.4 −0.2 0.2 0.4 0.6 0.8 1 time response
(Previous) ¡example ¡
5me ¡index ¡
Cross-‑correla5on ¡of ¡example ¡series ¡
figure; plot(xcorr(h, g),0 k0) xlabel(0time index (n)0) ylabel(0Cgh(n)0)
Signals ¡of ¡length ¡N ¡= ¡1000. ¡Cross-‑correla5on ¡of ¡length ¡2N-‑1. ¡ ¡
200 400 600 800 1000 1200 1400 1600 1800 2000 −500 −400 −300 −200 −100 100 200 300 400 500 time index (n) Cgh(n)
5me ¡index ¡
600 700 800 900 1000 1100 1200 1300 1400 −500 −400 −300 −200 −100 100 200 300 400 500 time index (n) Cgh(n)
Cross-‑correla5on ¡of ¡example ¡series ¡
- In ¡Cgh(n): ¡peak ¡at ¡le[. ¡Interpreta5on: ¡h ¡leads ¡g, ¡or ¡h ¡must ¡be ¡shi[ed ¡right ¡
(nega5ve ¡n) ¡to ¡line ¡up ¡with ¡g. ¡In ¡present ¡example, ¡cosine ¡(h) ¡leads ¡sine ¡(g) ¡in ¡
- phase. ¡ ¡
¡
- Mul5ple ¡peaks: ¡periodic ¡re-‑alignment ¡of ¡cos ¡with ¡sin ¡at ¡mul5ples ¡of ¡period ¡
- Cau5on! ¡Cgh(t) ¡is ¡ ¡xcorr(h,g) ¡in ¡Matlab: ¡note ¡reversed ¡order ¡of ¡g, ¡h! ¡ ¡ ¡
Matlab: ¡signals ¡of ¡length ¡N ¡have ¡0-‑shi[ ¡at ¡N ¡in ¡xcorr ¡
figure; plot(xcorr(h, g),0 k0) xlabel(0time index (n)0) ylabel(0Cgh(n)0)
Cross-‑correla5on ¡of ¡example ¡series ¡
figure; plot(xcorr(h, g),0 k0) xlabel(0time index (n)0) ylabel(0Cgh(n)0)
Decay ¡in ¡amplitude ¡due ¡to ¡finite ¡length ¡of ¡g, ¡h: ¡shi[ ¡n ¡is ¡a ¡sum ¡over ¡N-‑|n| ¡terms, ¡so ¡ amplitude ¡will ¡go ¡to ¡0 ¡as ¡shi[ ¡goes ¡to ¡N. ¡ ¡
200 400 600 800 1000 1200 1400 1600 1800 2000 −500 −400 −300 −200 −100 100 200 300 400 500 time index (n) Cgh(n)
5me ¡index ¡
Autocorrela5on ¡func5on ¡
- Special ¡case ¡of ¡cross-‑correla5on: ¡signal ¡
correla5on ¡with ¡itself ¡at ¡all ¡5me ¡shi[s. ¡ ¡
- Commonly ¡used ¡to ¡detect ¡temporal ¡paberns ¡
(periodic ¡or ¡otherwise) ¡within ¡noisy ¡5me-‑ series ¡data. ¡ ¡
- Symmetric; ¡central ¡peak ¡always ¡at ¡0 ¡5me-‑lag. ¡
Autocorrela5on ¡example ¡
600 700 800 900 1000 1100 1200 1300 1400 −500 −400 −300 −200 −100 100 200 300 400 500 time index (n) Cgg(n)
5me ¡index ¡
BACK ¡TO ¡A ¡MODELING ¡ PERSPECTIVE ¡
Overview ¡
Time-‑series ¡data ¡
g: ¡a ¡temporally ¡varying ¡signal ¡ ¡ sampled ¡at ¡discrete ¡intervals ¡
- If ¡g ¡is ¡5me-‑series ¡of ¡length ¡N, ¡then ¡N ¡variables ¡within ¡g. ¡ ¡
- But ¡then ¡should ¡construct ¡NxN ¡covariance ¡matrix ¡with ¡(α,β) ¡
entry ¡given ¡by ¡cov(gαgβ), ¡and ¡N(N+1)/2 ¡dis5nct ¡entries. ¡ ¡
- Autocorrela5on: ¡only ¡(2N-‑1)/2 ¡dis5nct ¡entries ¡(1/2 ¡because ¡
- f ¡symmetry ¡about ¡0-‑5me ¡lag). ¡ ¡
{g1, · · · , gN}
Autocorrela5on ¡and ¡5me-‑series ¡data ¡
¡ What ¡are ¡we ¡throwing ¡out ¡when ¡studying ¡only ¡the ¡autocorrelaIon ¡
- f ¡a ¡Ime-‑series ¡g ¡(N ¡disInct ¡entries), ¡compared ¡to ¡the ¡NxN ¡ ¡
covariance ¡matrix ¡of ¡its ¡components ¡(N(N+1)/2 ¡disInct ¡entries)? ¡ ¡ ¡ ¡
Autocorrela5on ¡and ¡5me-‑series ¡data ¡
- One ¡entry ¡in ¡cross-‑correla5on ¡measures ¡rela5onship ¡
between ¡terms ¡in ¡g ¡at ¡a ¡fixed ¡5me-‑lag, ¡summed ¡over ¡ all ¡=mes. ¡
- Assump5on ¡of ¡=me ¡transla=on-‑invariance: ¡
rela5onship ¡between ¡terms ¡in ¡g ¡at ¡lag ¡n ¡is ¡similar, ¡ regardless ¡of ¡star5ng ¡5me. ¡ ¡(E.g. ¡whenever ¡a ¡cell ¡ spikes, ¡it ¡will ¡tend ¡not ¡to ¡spike ¡for ¡2 ¡ms: ¡refractory ¡
- period. ¡Pabern ¡independent ¡of ¡actual ¡spike ¡5me.) ¡
- Same ¡assump5on ¡in ¡cross-‑correla5on. ¡ ¡
Summary ¡
- Time-‑series ¡inherently ¡more ¡complex ¡than ¡random ¡draws ¡
from ¡a ¡sta5onary ¡system. ¡
- Look ¡for: ¡transla5on-‑invariant ¡temporal ¡paberns ¡within ¡
and ¡across ¡5me-‑series. ¡
- Auto-‑ ¡and ¡cross-‑correla5on ¡func5ons. ¡
- Each ¡term ¡an ¡average ¡across ¡the ¡en5re ¡5me-‑series: ¡
reduced ¡noise. ¡ ¡
SPIKE ¡TRAINS: ¡CROSS-‑CORRELATION ¡ AND ¡SIMPLE ¡STATISTICS ¡
Applica5on ¡
Mo5on ¡detec5on ¡in ¡the ¡blowfly ¡
Image ¡by ¡Muhammad ¡Mahdi ¡Karim, ¡published ¡under ¡ GNU ¡Free ¡Documenta5on ¡License, ¡Version ¡1.2 ¡ ¡ ¡
H1 ¡neuron: ¡horizontal ¡mo5on ¡sensing ¡
Single ¡H1 ¡neuron ¡ in ¡lobula ¡plate ¡of ¡ ¡ each ¡hemisphere ¡ Lobula ¡plate: ¡ ¡ highest ¡visual ¡ ¡ area, ¡before ¡ ¡ motor ¡output. ¡
H1 ¡response ¡during ¡horizontal ¡visual ¡mo5on ¡
- Data: ¡Rob ¡de ¡Ruyter ¡van ¡Steveninck ¡
- 500 ¡Hz, ¡spikes ¡and ¡whole-‑field ¡horizontal ¡mo5on ¡s5mulus ¡
100 200 300 400 500 600 700 800 900 1000 −150 −100 −50 50 100 150 sample number (500 Hz) stim, H1 spks
Spike ¡autocorrela5on ¡
5.999 5.9992 5.9994 5.9996 5.9998 6 6.0002 6.0004 6.0006 6.0008 6.001 x 10
5
0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 x 10
4
sample number C(rho, rho)
Spike ¡autocorrela5on ¡
5.999 5.9992 5.9994 5.9996 5.9998 6 6.0002 6.0004 6.0006 6.0008 6.001 x 10
5
0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 x 10
4
sample number C(rho, rho)
Large ¡narrow ¡peak ¡at ¡zero. ¡Why? ¡ What ¡does ¡its ¡height ¡mean? ¡
Spike ¡autocorrela5on ¡
5.999 5.9992 5.9994 5.9996 5.9998 6 6.0002 6.0004 6.0006 6.0008 6.001 x 10
5
0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 x 10
4
sample number C(rho, rho)
Sharp ¡narrow ¡dip. ¡What ¡does ¡this ¡mean? ¡ Where ¡could ¡it ¡come ¡from? ¡ ¡
Spike ¡autocorrela5on ¡
5.999 5.9992 5.9994 5.9996 5.9998 6 6.0002 6.0004 6.0006 6.0008 6.001 x 10
5
0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 x 10
4
sample number C(rho, rho)
Posi5ve ¡slowly ¡decaying ¡transient. ¡ What ¡does ¡this ¡mean? ¡Where ¡could ¡ it ¡come ¡from? ¡ ¡
S5mulus ¡autocorrela5on ¡
5.999 5.9992 5.9994 5.9996 5.9998 6 6.0002 6.0004 6.0006 6.0008 6.001 x 10
5
5 10 15 x 10
8
sample number C(stim, stim)
S5mulus ¡autocorrela5on ¡
5.999 5.9992 5.9994 5.9996 5.9998 6 6.0002 6.0004 6.0006 6.0008 6.001 x 10
5
5 10 15 x 10
8
sample number C(stim, stim)
Medium-‑width ¡peak ¡at ¡zero. ¡ ¡ What ¡does ¡its ¡height ¡mean? ¡
S5mulus, ¡spike ¡autocorrela5ons ¡
5.999 5.9992 5.9994 5.9996 5.9998 6 6.0002 6.0004 6.0006 6.0008 6.001 x 10
5
−0.2 0.2 0.4 0.6 0.8 1 1.2 sample number C(rho, rho), C(stim, stim)
Can ¡s5mulus ¡correla5ons ¡explain ¡spike ¡correla5ons? ¡
S5mulus, ¡spike ¡cross-‑correla5on ¡
5.997 5.998 5.999 6 6.001 6.002 6.003 x 10
5
−2 2 4 6 8 10 12 14 16 x 10
5
sample number (500 Hz) C(stim, rho)
When ¡s5mulus ¡goes ¡up ¡(more ¡ posi5ve ¡velocity), ¡response ¡ increases: ¡posi5ve ¡peak. ¡ Response ¡lags ¡s5mulus ¡(peak ¡to ¡right ¡of ¡zero-‑shi[). ¡ ¡ ¡
S5mulus, ¡spike ¡cross-‑correla5on ¡
5.997 5.998 5.999 6 6.001 6.002 6.003 x 10
5−2 2 4 6 8 10 12 14 16 x 10
5sample number (500 Hz) C(stim, rho)
What ¡does ¡s5mulus, ¡response ¡cross-‑correla5on ¡really ¡mean, ¡ ¡ from ¡modeling ¡perspec5ve? ¡
WHAT ¡DOES ¡IT ¡MEAN ¡TO ¡BUILD ¡A ¡ MODEL ¡OF ¡OBSERVATIONS ¡IN ¡THIS ¡ EXPERIMENT? ¡
Back ¡to ¡original ¡goal: ¡Modeling ¡
Modeling ¡
- Rela5vely ¡simple/compact ¡descrip5on ¡of ¡data, ¡
good ¡predic5on ¡performance. ¡ ¡
- Extrac5ng ¡“features” ¡of ¡data ¡as ¡a ¡way ¡to ¡
model ¡it. ¡ ¡
- To ¡determine ¡predictability, ¡important ¡to ¡
cross-‑validate ¡models/fits. ¡ ¡
Modeling ¡spike ¡train ¡data ¡
Model: ¡Simple, ¡predic5ve ¡descrip5on. ¡But ¡of ¡ what? ¡
- Given ¡s5mulus, ¡ ¡predict ¡spikes? ¡
- Given ¡spikes, ¡“predict” ¡s5mulus? ¡
Modeling ¡spike ¡train ¡data ¡
Model: ¡Simple, ¡predic5ve ¡descrip5on. ¡But ¡of ¡ what? ¡
- Given ¡s5mulus, ¡ ¡predict ¡spikes? ¡
- Given ¡spikes, ¡“predict” ¡s5mulus? ¡
Encoding ¡model ¡ Decoding ¡model ¡
Yes, ¡both! ¡
Summary ¡
- Autocorrela5ons ¡of ¡s5mulus, ¡response ¡tell ¡us ¡about ¡
structure ¡within ¡s5mulus, ¡response. ¡ ¡
- Comparison ¡of ¡the ¡autocorrela5ons ¡helps ¡understand ¡
differences ¡in ¡the ¡structure ¡and ¡mo5vates ¡us ¡to ¡search ¡for ¡ causes ¡for ¡these ¡differences. ¡ ¡
- Cross-‑correla5on ¡tells ¡us ¡about ¡some ¡rela5onships ¡
between ¡s5mulus ¡and ¡response: ¡5me-‑lags, ¡sign ¡of ¡ rela5onship, ¡etc. ¡ ¡ ¡
- Beber ¡understanding ¡of ¡what ¡s5mulus, ¡response ¡cross-‑