-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathrandom-process-examples.Rmd
More file actions
92 lines (80 loc) · 2.99 KB
/
random-process-examples.Rmd
File metadata and controls
92 lines (80 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Examples of Random Processes {#random-process-examples}
In this lesson, we cover a few more examples of random processes.
```{example random-amplitude, name="Random Amplitude Process"}
Let $A$ be a random variable. Let $f$ be a constant. Then the continuous-time process
\[ X(t) = A\cos(2\pi f t) \]
is called a **random amplitude** process.
Note that once the value of $A$ is simulated, the random process $\{ X(t) \}$ is
completely specified for all times $t$.
Shown below are 30 realizations of
the random amplitude process, where $A$ is $\text{Binomial}(n=5, p=0.5)$.
```
```{r, echo=FALSE, fig.show = "hold", fig.align = "default"}
plot(NA, NA,
xaxt="n", yaxt="n", bty="n",
xlim=c(-2, 3), ylim=c(-5.1, 5.1),
xlab="Time (t)", ylab="X(t)")
axis(1, pos=0)
axis(2, pos=0)
set.seed(1)
ts <- seq(-2, 3, by=0.01)
a <- rbinom(30, 5, 0.5)
for(i in 1:30) {
lines(ts, a[i] * cos(2 * pi * ts), col=rgb(0, 0, 1, 0.2))
}
```
Here is a video that animates the random amplitude process.
<iframe width="560" height="315" src="https://www.youtube.com/embed/vU8yW3e-8-c" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
```{example ma1, name="Moving Average Process"}
Let $\{ Z[n] \}$ be a white noise process. Then, a **moving average process** (of order 1) $\{ X[n] \}$
is a discrete-time process defined by
\begin{equation}
X[n] = b_0 Z[n] + b_1 Z[n-1].
(\#eq:ma1)
\end{equation}
Below, we show one realization of a white noise process $\{ Z[n] \}$ (in orange),
along with the corresponding moving average process
\[ X[n] = 0.5 Z[n] + 0.5 Z[n-1]. \]
Notice that the moving average process is just the average of successive values of the
white noise process. As a result, the moving average process is "smoother" than the white noise process.
```
```{r, echo=FALSE, fig.show = "hold", fig.align = "default"}
set.seed(1)
ts <- -2:7
Z <- rnorm(10)
plot(ts, Z, col="orange", pch=19,
xaxt="n", yaxt="n", bty="n",
xlim=c(0, 6), ylim=c(-3, 3),
xlab="Time Sample (n)", ylab="Value of the Process")
lines(ts, Z, col="orange")
axis(1, pos=0)
axis(2, pos=0)
X <- c()
for(i in 2:10) {
X <- c(X, (Z[i] + Z[i-1]) / 2)
}
points(-1:7, X, col="blue", pch=19)
lines(-1:7, X, col="blue", lwd=2)
legend(4, 3, c("White Noise", "Moving Average"), lty=1, lwd=c(1, 2), col=c("orange", "blue"))
```
Now, we show 30 realizations of the same moving average process. Superficially, this might
look like the white noise of Example \@ref(exm:white-noise), but if you look closely, you will
see that each individual function fluctuates less.
```{r, echo=FALSE, fig.show = "hold", fig.align = "default"}
set.seed(1)
plot(NA, NA,
xaxt="n", yaxt="n", bty="n",
xlim=c(0, 6), ylim=c(-3, 3),
xlab="Time Sample (n)", ylab="X[n]")
axis(1, pos=0)
axis(2, pos=0)
for(i in 1:30) {
Z <- rnorm(10)
X <- c()
for(i in 2:10) {
X <- c(X, (Z[i] + Z[i-1]) / 2)
}
points(-1:7, X, col=rgb(0, 0, 1, 0.2), pch=19)
lines(-1:7, X, col=rgb(0, 0, 1, 0.2), lwd=2)
}
```