Skip to content

Commit

Permalink
Almost done...
Browse files Browse the repository at this point in the history
  • Loading branch information
saravia committed Nov 27, 2015
1 parent 3e7525f commit b41e8e5
Show file tree
Hide file tree
Showing 12 changed files with 376 additions and 6 deletions.
Binary file added main-figure/unnamed-chunk-10-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added main-figure/unnamed-chunk-11-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added main-figure/unnamed-chunk-12-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added main-figure/unnamed-chunk-13-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added main-figure/unnamed-chunk-9-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
230 changes: 227 additions & 3 deletions main.Rpres
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ $f:\mathbb{R}\rightarrow\mathbb{C}$
$$
\begin{aligned}
f(x) &= \int_{-\infty}^\infty F(s) e^{2\pi i s x} ds \\
F(s) &= \int_{-\infty}^\infty f(x) e^{-2\pi i s x} ds \\
F(s) &= \int_{-\infty}^\infty f(x) e^{-2\pi i s x} dx \\
\end{aligned}
$$

Expand Down Expand Up @@ -327,17 +327,241 @@ plot(freqs / w1,Pv, type="b",
par(mfrow = c(1,1))
```

Example: Time-varying signal 2
========================================================

```{r, echo=FALSE}
N <- 1024*256
w1 <- 5
w2 <- 0.7
w3 <- 1
a1 <- 15
a2 <- 3
a3 <- 1
mu <- 5
sigma <- 0.5
noise <- 3

x <- seq(from=0, to=10,length.out = N)

y0 <- a1*sin(w1*x*2*pi)*dnorm(x, mu, sigma)
y1 <- a2*sin(w2*x*2*pi) + a3*sin(w3*x*2*pi)
y <- y0 + y1 + rnorm(n = N, mean = 0, sd = noise)
par(mfrow = c(2,1))
plot(x,y1,type="l", ylim = c(-10, 10),
xlab = "t",
ylab = "f(t)")
lines(x,y0, col = "blue", lwd=2)
plot(x,y,type="l",
xlab = "t",
ylab = "f(t)")
par(mfrow = c(1,1))
```

***

```{r, echo=FALSE}
Dt <- (max(x) - min(x)) / N
Dw <- 1 / (N * Dt)
Y <- fft(y)/N
P <- Mod(Y)^2
freqs <- (seq(from=0, to=N-1) * Dw)
plot(freqs / w1,P, type="b",
xlim=c(0,1.2),
xlab = expression("w/w"[1]),
ylab = "P")
```


Short-time Fourier Transform (STFT)
========================================================
incremental: true

Make Fourier Transform of *short* segments in the timeseries using a *window* function centered at $\tau$, $w(t-\tau)$

$$\hat{F}(\omega, \tau) =
\int_{-\infty}^\infty f(t) w(t-\tau) e^{-2\pi i \omega t} dt$$

**Problem:** Choose an appropriate window width

Frequency vs. time resolution


Wavelet transforms
========================================================
incremental: true

**Idea:**

- Narrow windows for large frequencies (good time resolution)
- Wide windows for small frequencies (good frequency resolution)

Choose a *localized wave* (mother wavelet) $\psi(t)$ and define

$$\psi_{a,b}(t)=\frac{1}{\sqrt{a}}\psi\left(\frac{t-b}{a}\right)$$

Wavelet transforms
========================================================
incremental: true

Example: Mexican-hat wavelet

$$\psi(t) = \left(1-t^2\right)e^{-t^2/2}$$
$$\psi_{a,b}(t)=\frac{1}{\sqrt{a}}\psi\left(\frac{t-b}{a}\right)$$

***

```{r,echo=FALSE}
mhw <- function(t, a, b) {
return((1/sqrt(a)) * (1-((t-b)/a)^2) * exp(-((t-b)/a)^2/2))
}
x <- seq(from=-5, to=5, length.out = 1000)
y0 <- mhw(x,1.2,0)
y1 <- mhw(x,0.2,0)
plot(x,y1, type="l", xlab = "t", ylab = expression(psi))
text(0.6,2, labels = "a=0.2")
lines(x,y0, col="blue")
text(1,0.8, labels = "a=1.2", col="blue")
```


Definition of wavelet transforms
========================================================

Given $f\in L^2(\mathbb{R})$, we define its *continuous wavelet transform* with respect to the wavelet $\psi$ as

$$\mathcal{W}_{\psi}[f] (a,b) = \int_{-\infty}^\infty f(t)\overline{\psi_{a,b}(t)}dt$$

For $\mathcal{W}_\psi[f]$ to be invertible we require

$$ 0 < C_{\psi}\equiv\int_{-\infty}^\infty
\frac{\left|\hat{\psi}(\omega)\right|^2}{\left|\omega\right|} d\omega
<\infty $$

Example: Time-varying signal CWT
========================================================

```{r, echo=FALSE}
N <- 1024*256
w1 <- 5
w2 <- 0.7
w3 <- 1
a1 <- 15
a2 <- 3
a3 <- 1
mu <- 5
sigma <- 0.5
noise <- 3

x <- seq(from=0, to=10,length.out = N)

y0 <- a1*sin(w1*x*2*pi)*dnorm(x, mu, sigma)
y1 <- a2*sin(w2*x*2*pi) + a3*sin(w3*x*2*pi)
y <- y0 + y1 + rnorm(n = N, mean = 0, sd = noise)
par(mfrow = c(2,1))
plot(x,y,type="l",
xlab = "t",
ylab = "f(t)")
Dt <- (max(x) - min(x)) / N
Dw <- 1 / (N * Dt)
Y <- fft(y)/N
P <- Mod(Y)^2
freqs <- (seq(from=0, to=N-1) * Dw)
plot(freqs / w1,P, type="b",
xlim=c(0,1.2),
xlab = expression("w/w"[1]),
ylab = "P")
par(mfrow=c(1,1))
```

***

Mexican hat CWT

![](tvs1.png)

Example: Time-varying signal CWT 2
========================================================

Haar CWT

![](tvs2.png)

***

Morlet CWT

![](tvs3.png)


Example: Time-varying signal CWT 3
========================================================

Morlet

![](tvs4.png)

***

Mexican-hat

![](tvs5.png)


Parseval's relation for wavelets
========================================================

$$
\int_{-\infty}^\infty\int_{-\infty}^\infty \mathcal{W}_\psi f (a,b)\overline{\mathcal{W}_\psi g (a,b)} \frac{da db}{a^2} = C_{\psi}\langle f,g\rangle
$$

where

$$
C_\psi \equiv \int_{-\infty}^\infty \frac{|\hat{\psi}(\omega)|^2}{|\omega|}d\omega
$$


Inverse of a wavelet transform
========================================================

$$f(t) = \frac{1}{C_\psi}\int_{-\infty}^\infty\int_{-\infty}^\infty \mathcal{W}_\psi[f](a,b) \psi_{a,b}(t) \frac{da\ db}{a^2}$$


Discrete wavelet transform
========================================================
incremental: true

Change the continuous version

$$\psi_{a,b}(t) = \frac{1}{\sqrt{a}} \psi\left(\frac{t-b}{a}\right),\ \ a,b\in\mathbb{R},\ a\neq 0 $$

to a discrete version

$$\psi_{m,n}(t)=2^{-m/2} \psi \left( 2^{-m} t - n \right),\ \ \ n,m \in \mathbb{Z}$$

When can we recover $f(t)$ from $\mathcal{W}_\psi[f](m,n)$ ?


Discrete wavelet transform 2
========================================================

When $\psi_{m,n}$ is complete in and orthonormal in $L^2(\mathbb{R})$:

$$f(t) = \sum_{m,n=-\infty}^\infty \langle f,\psi_{m,n}\rangle\ \psi_{m,n}(t)$$


Multiresolution analysis (MRA)
========================================================

> MRA is really an effective mathematical framework for hierarchical decomposition of an image (or signal) into components of different scales (or frequencies).

Used to make *time-frequency* analysis


Orthogonality relations
========================================================

$$\int_{-\infty}^\infty e^{2\pi i (x-x')}dx' = \delta(x) $$
$$\int_{-\infty}^\infty e^{2\pi i (x-x')}dx' = \delta(x)$$

$$\int_0^p e^{2\pi i x (k-l)/p}dx =
\begin{cases}
Expand Down
Loading

0 comments on commit b41e8e5

Please sign in to comment.