From 098c29fb0b0469787f8441be3aac3e26e4bd3b85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Giorgi=20Tsutskiridze=20=28=E1=83=92=E1=83=98=E1=83=9D?= =?UTF-8?q?=E1=83=A0=E1=83=92=E1=83=98=20=E1=83=AA=E1=83=A3=E1=83=AA?= =?UTF-8?q?=E1=83=A5=E1=83=98=E1=83=A0=E1=83=98=E1=83=AB=E1=83=94=29?= Date: Tue, 30 Mar 2021 16:06:50 +0400 Subject: [PATCH 1/5] Solution to Exercise 2 I have changed the way the labels are constructed for different alpha values in the legend. In the hint for the exercise 2 you mentioned string concatenation as well as str() function for constructing labels for different alpha values, however in the solution you used f string. So, may be it would be better to show first how string concatenation is sed and then propose f string as an alternative version. --- lectures/python_by_example.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lectures/python_by_example.md b/lectures/python_by_example.md index 9967a1c2..8c9151c1 100644 --- a/lectures/python_by_example.md +++ b/lectures/python_by_example.md @@ -475,8 +475,8 @@ 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. @@ -484,8 +484,8 @@ 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 @@ -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() From e01c07791148ee5e04b81e4559591046f2c3d993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Giorgi=20Tsutskiridze=20=28=E1=83=92=E1=83=98=E1=83=9D?= =?UTF-8?q?=E1=83=A0=E1=83=92=E1=83=98=20=E1=83=AA=E1=83=A3=E1=83=AA?= =?UTF-8?q?=E1=83=A5=E1=83=98=E1=83=A0=E1=83=98=E1=83=AB=E1=83=94=29?= Date: Thu, 1 Apr 2021 15:17:11 +0400 Subject: [PATCH 2/5] Corrected typo on line 501 --- lectures/python_by_example.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lectures/python_by_example.md b/lectures/python_by_example.md index 9967a1c2..ba5c962f 100644 --- a/lectures/python_by_example.md +++ b/lectures/python_by_example.md @@ -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|$. From 94f2bd5805d177e13700c9486366fdccf187ee5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Giorgi=20Tsutskiridze=20=28=E1=83=92=E1=83=98=E1=83=9D?= =?UTF-8?q?=E1=83=A0=E1=83=92=E1=83=98=20=E1=83=AA=E1=83=A3=E1=83=AA?= =?UTF-8?q?=E1=83=A5=E1=83=98=E1=83=A0=E1=83=98=E1=83=AB=E1=83=94=29?= Date: Thu, 1 Apr 2021 15:29:56 +0400 Subject: [PATCH 3/5] Update python_by_example.md --- lectures/python_by_example.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lectures/python_by_example.md b/lectures/python_by_example.md index 6668a123..e6d022b2 100644 --- a/lectures/python_by_example.md +++ b/lectures/python_by_example.md @@ -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|$. From 8b1b81370e297df6f2708ff3e41a0fccef82a4f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Giorgi=20Tsutskiridze=20=28=E1=83=92=E1=83=98=E1=83=9D?= =?UTF-8?q?=E1=83=A0=E1=83=92=E1=83=98=20=E1=83=AA=E1=83=A3=E1=83=AA?= =?UTF-8?q?=E1=83=A5=E1=83=98=E1=83=A0=E1=83=98=E1=83=AB=E1=83=94=29?= Date: Thu, 1 Apr 2021 17:14:11 +0400 Subject: [PATCH 4/5] Correcting typos --- lectures/python_by_example.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lectures/python_by_example.md b/lectures/python_by_example.md index e6d022b2..0e7c77e1 100644 --- a/lectures/python_by_example.md +++ b/lectures/python_by_example.md @@ -471,7 +471,7 @@ 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 From 681280869d0d35a2c2915cac0b123eaefd6db349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Giorgi=20Tsutskiridze=20=28=E1=83=92=E1=83=98=E1=83=9D?= =?UTF-8?q?=E1=83=A0=E1=83=92=E1=83=98=20=E1=83=AA=E1=83=A3=E1=83=AA?= =?UTF-8?q?=E1=83=A5=E1=83=98=E1=83=A0=E1=83=98=E1=83=AB=E1=83=94=29?= Date: Thu, 1 Apr 2021 17:35:28 +0400 Subject: [PATCH 5/5] Minor typo in text --- lectures/python_by_example.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lectures/python_by_example.md b/lectures/python_by_example.md index 0e7c77e1..294c18ef 100644 --- a/lectures/python_by_example.md +++ b/lectures/python_by_example.md @@ -476,7 +476,7 @@ Set $T=200 \,$ and $\alpha = 0.9$. ### Exercise 2 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$. +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.