Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions lectures/python_by_example.md
Original file line number Diff line number Diff line change
Expand Up @@ -471,21 +471,21 @@ import numpy as np
import matplotlib.pyplot as plt
```

Set $T=200$ and $\alpha = 0.9$.
Set $T=200 \,$ and $\alpha = 0.9$.

### Exercise 2

Starting with your solution to exercise 2, plot three simulated time series,
one for each of the cases $\alpha=0$, $\alpha=0.8$ and $\alpha=0.98$.
Starting with your solution to exercise 1, plot three simulated time series,
one for each of the cases: $\alpha=0$, $\alpha=0.8 \,$ and $\alpha=0.98$.

Use a `for` loop to step through the $\alpha$ values.

If you can, add a legend, to help distinguish between the three time series.

Hints:

* If you call the `plot()` function multiple times before calling `show()`, all of the lines you produce will end up on the same figure.
* For the legend, noted that the expression `'foo' + str(42)` evaluates to `'foo42'`.
* If you call a `plot()` function multiple times before calling a `show()`, all of the lines you produce will end up on the same figure.
* For the legend, note that the expression `'foo' + str(42)` evaluates to `'foo42'`.

### Exercise 3

Expand All @@ -498,7 +498,7 @@ x_0 = 0
\quad \text{and} \quad t = 0,\ldots,T
$$

Use $T=200$, $\alpha = 0.9$ and $\{\epsilon_t\}$ as before.
Use $T=200$, $\alpha = 0.9 \, $ and $\{\epsilon_t\}$ as before.

Search online for a function that can be used to compute the absolute value $|x_t|$.

Expand Down Expand Up @@ -578,7 +578,7 @@ for α in α_values:
x[0] = 0
for t in range(T):
x[t+1] = α * x[t] + np.random.randn()
plt.plot(x, label=f'$\\alpha = {α}$')
plt.plot((x, label = 'α = ' + str(α)) or we can also use plt.plot(x, label=f'$\\alpha = {α}$')

plt.legend()
plt.show()
Expand Down