From f16740e28f2eb59d86b57663b412fd8275bae028 Mon Sep 17 00:00:00 2001 From: Smit-create Date: Mon, 3 Jul 2023 13:41:57 +0530 Subject: [PATCH 1/2] Move ex 2 #4 to ex 3 #4 --- day-02/exercise_set_2.ipynb | 53 +--------- day-02/exercise_set_2_with_solution.ipynb | 119 +--------------------- day-03/exercise_set_3.ipynb | 36 ++++++- day-03/exercise_set_3_with_solution.ipynb | 93 ++++++++++++++++- 4 files changed, 129 insertions(+), 172 deletions(-) diff --git a/day-02/exercise_set_2.ipynb b/day-02/exercise_set_2.ipynb index 8617dc3..ad91a4e 100644 --- a/day-02/exercise_set_2.ipynb +++ b/day-02/exercise_set_2.ipynb @@ -1,7 +1,6 @@ { "cells": [ { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -9,7 +8,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -19,7 +17,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -40,7 +37,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -52,7 +48,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -86,7 +81,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -119,7 +113,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -154,7 +147,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -187,7 +179,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -226,7 +217,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -234,7 +224,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -270,7 +259,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -305,7 +293,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -313,7 +300,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -321,7 +307,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -406,42 +391,6 @@ "source": [ "# TODO: Write your code here" ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Exercise 4" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Generate 100000 data points from the [exponential distribution](https://en.wikipedia.org/wiki/Exponential_distribution) with density\n", - "\n", - "$$\n", - "f(x; \\alpha) = \\alpha \\exp(-\\alpha x)\n", - "\\qquad\n", - "(x > 0, \\alpha > 0)\n", - "$$\n", - "\n", - "taking $\\alpha = 0.5$. Then\n", - "\n", - "1. Plot a histogram of your sample and compare it to the density of the exponential distribution.\n", - "2. After looking up the maximum likelihood estimator of $\\alpha$, compute the estimate given your data and check that it is in fact close to $\\alpha$." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# TODO: Put your solution here" - ] } ], "metadata": { @@ -460,7 +409,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.9" + "version": "3.10.11" } }, "nbformat": 4, diff --git a/day-02/exercise_set_2_with_solution.ipynb b/day-02/exercise_set_2_with_solution.ipynb index b448c6e..0df841a 100644 --- a/day-02/exercise_set_2_with_solution.ipynb +++ b/day-02/exercise_set_2_with_solution.ipynb @@ -1,7 +1,6 @@ { "cells": [ { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -9,7 +8,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -19,7 +17,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -40,7 +37,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -52,7 +48,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -85,7 +80,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -117,7 +111,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -151,7 +144,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -183,7 +175,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -222,7 +213,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -230,7 +220,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -265,7 +254,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -301,7 +289,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -309,7 +296,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -317,7 +303,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -418,108 +403,6 @@ "\n", "plt.show()" ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Exercise 4" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Generate 100000 data points from the [exponential distribution](https://en.wikipedia.org/wiki/Exponential_distribution) with density\n", - "\n", - "$$\n", - "f(x; \\alpha) = \\alpha \\exp(-\\alpha x)\n", - "\\qquad\n", - "(x > 0, \\alpha > 0)\n", - "$$\n", - "\n", - "taking $\\alpha = 0.5$. Then\n", - "\n", - "1. Plot a histogram of your sample and compare it to the density of the exponential distribution.\n", - "2. After looking up the maximum likelihood estimator of $\\alpha$, compute the estimate given your data and check that it is in fact close to $\\alpha$." - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Solution" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "After checking [the docs for the exponential distribution](http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.expon.html) we proceed as follows" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from scipy.stats import expon\n", - "import numpy as np\n", - "\n", - "alpha = 0.5\n", - "n = int(1e5)\n", - "# Scale controls the exponential parameter\n", - "ep = expon(scale=1.0/alpha)\n", - "# Generate n randome variables\n", - "x = ep.rvs(size=n)" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Here's a histogram and density." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "fig, ax = plt.subplots(figsize=(8, 5))\n", - "xmin, xmax = 0.001, 10.0\n", - "ax.set_xlim(xmin, xmax)\n", - "ax.hist(x, density=True, bins=60, alpha=0.3)\n", - "grid = np.linspace(xmin, xmax, 200)\n", - "ax.plot(grid, ep.pdf(grid), 'k-', lw=2, label='true density')\n", - "ax.legend()\n", - "plt.show()" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "It's [well-known](http://en.wikipedia.org/wiki/Exponential_distribution) that the MLE of $\\alpha$ is $1/\\bar x$ where $\\bar x$ is the mean of the sample. Let's check that it is indeed close to $\\alpha$." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "alpha_mle = 1.0 / x.mean()\n", - "print(f\"max likelihood estimate of alpha is {alpha_mle}.\")" - ] } ], "metadata": { @@ -538,7 +421,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.10.11" } }, "nbformat": 4, diff --git a/day-03/exercise_set_3.ipynb b/day-03/exercise_set_3.ipynb index 3a79165..dd323ed 100644 --- a/day-03/exercise_set_3.ipynb +++ b/day-03/exercise_set_3.ipynb @@ -354,6 +354,40 @@ "except:\n", " print(\"Wrong answer, please check your code again.\")" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Exercise 4" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Generate 100000 data points from the [exponential distribution](https://en.wikipedia.org/wiki/Exponential_distribution) with density\n", + "\n", + "$$\n", + "f(x; \\alpha) = \\alpha \\exp(-\\alpha x)\n", + "\\qquad\n", + "(x > 0, \\alpha > 0)\n", + "$$\n", + "\n", + "taking $\\alpha = 0.5$. Then\n", + "\n", + "1. Plot a histogram of your sample and compare it to the density of the exponential distribution.\n", + "2. After looking up the maximum likelihood estimator of $\\alpha$, compute the estimate given your data and check that it is in fact close to $\\alpha$." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# TODO: Write your code here" + ] } ], "metadata": { @@ -377,7 +411,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.10.11" } }, "nbformat": 4, diff --git a/day-03/exercise_set_3_with_solution.ipynb b/day-03/exercise_set_3_with_solution.ipynb index dda06c8..8717582 100644 --- a/day-03/exercise_set_3_with_solution.ipynb +++ b/day-03/exercise_set_3_with_solution.ipynb @@ -366,6 +366,97 @@ "except:\n", " print(\"Wrong answer, please check your code again.\")" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Exercise 4" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Generate 100000 data points from the [exponential distribution](https://en.wikipedia.org/wiki/Exponential_distribution) with density\n", + "\n", + "$$\n", + "f(x; \\alpha) = \\alpha \\exp(-\\alpha x)\n", + "\\qquad\n", + "(x > 0, \\alpha > 0)\n", + "$$\n", + "\n", + "taking $\\alpha = 0.5$. Then\n", + "\n", + "1. Plot a histogram of your sample and compare it to the density of the exponential distribution.\n", + "2. After looking up the maximum likelihood estimator of $\\alpha$, compute the estimate given your data and check that it is in fact close to $\\alpha$." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Solution\n", + "\n", + "After checking [the docs for the exponential distribution](http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.expon.html) we proceed as follows" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from scipy.stats import expon\n", + "import numpy as np\n", + "\n", + "alpha = 0.5\n", + "n = int(1e5)\n", + "# Scale controls the exponential parameter\n", + "ep = expon(scale=1.0/alpha)\n", + "# Generate n randome variables\n", + "x = ep.rvs(size=n)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Here's a histogram and density." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, ax = plt.subplots(figsize=(8, 5))\n", + "xmin, xmax = 0.001, 10.0\n", + "ax.set_xlim(xmin, xmax)\n", + "ax.hist(x, density=True, bins=60, alpha=0.3)\n", + "grid = np.linspace(xmin, xmax, 200)\n", + "ax.plot(grid, ep.pdf(grid), 'k-', lw=2, label='true density')\n", + "ax.legend()\n", + "plt.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "It's [well-known](http://en.wikipedia.org/wiki/Exponential_distribution) that the MLE of $\\alpha$ is $1/\\bar x$ where $\\bar x$ is the mean of the sample. Let's check that it is indeed close to $\\alpha$." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "alpha_mle = 1.0 / x.mean()\n", + "print(f\"max likelihood estimate of alpha is {alpha_mle}.\")" + ] } ], "metadata": { @@ -389,7 +480,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.10.11" } }, "nbformat": 4, From e83d987326fad28c8fb20e81f966788d454d3b8a Mon Sep 17 00:00:00 2001 From: Smit-create Date: Mon, 3 Jul 2023 14:14:53 +0530 Subject: [PATCH 2/2] Add new exercises --- day-02/exercise_set_2.ipynb | 97 ++++++++++++++++--- day-02/exercise_set_2_with_solution.ipynb | 111 +++++++++++++++++++--- 2 files changed, 181 insertions(+), 27 deletions(-) diff --git a/day-02/exercise_set_2.ipynb b/day-02/exercise_set_2.ipynb index ad91a4e..1f3538b 100644 --- a/day-02/exercise_set_2.ipynb +++ b/day-02/exercise_set_2.ipynb @@ -4,14 +4,14 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Linear Algebra and Probability Distributions Exercises" + "# Python and Linear Algebra Exercises" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "
" ] @@ -21,7 +21,7 @@ "metadata": {}, "source": [ "#### Written for the QuantEcon Africa Workshop (July 2023)\n", - "#### Author: [John Stachurski](http://johnstachurski.net/) and [Hengcheng Zhang](https://github.com/HengchengZhang)" + "#### Author: [John Stachurski](http://johnstachurski.net/) , [Hengcheng Zhang](https://github.com/HengchengZhang), and [Smit Lunagariya](https://github.com/Smit-create)" ] }, { @@ -42,6 +42,72 @@ "source": [ "### Exercise 1\n", "\n", + "Complete the following function that returns the number of odd elements in the given list." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def get_odd_num_from_list(nums):\n", + " # TODO: Finish this function\n", + " pass" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Test the solution\n", + "try:\n", + " assert get_odd_num_from_list([1, 2, 3]) == 2\n", + " assert get_odd_num_from_list(list(range(1, 20))) == 10\n", + " assert get_odd_num_from_list(list(range(0, 20, 2))) == 0\n", + " print(\"Congratulations!\")\n", + "except:\n", + " print(\"Wrong answer, please check your code again.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Exercise 2\n", + "\n", + "Consider the following time-series\n", + "\n", + "$$\n", + " a_{t+1} = (0.5 + r)a_t - br^2a_t\n", + "$$\n", + "\n", + "Assume that $r=0.05$, $b=100$ and $a_0=1.5$.\n", + "\n", + "Generate and plot the sequence $a_0, a_1, ..., a_T$.\n", + "\n", + "Use NumPy arrays to store the sequence $a$.\n", + "\n", + "Use $T=25$." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# TODO: Write your solution here" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Exercise 3\n", + "\n", "Warm up on NumPy Basics.\n", "\n", "Feel free to refer to the [numpy documentation](https://numpy.org/doc/stable/reference/index.html) for API." @@ -51,7 +117,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "**Exercise 1.1**: Write a function that creates numpy array from the given list/tuple." + "**Exercise 3.1**: Write a function that creates numpy array from the given list/tuple." ] }, { @@ -84,7 +150,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "**Exercise 1.2**: Write a function to return the transpose of the given matrix." + "**Exercise 3.2**: Write a function to return the transpose of the given matrix." ] }, { @@ -116,7 +182,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "**Exercise 1.3**: Write a function to return the inverse of the given matrix." + "**Exercise 3.3**: Write a function to return the inverse of the given matrix." ] }, { @@ -150,7 +216,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "**Exercise 1.4**: Write a function to compute the norm of the vector." + "**Exercise 3.4**: Write a function to compute the norm of the vector." ] }, { @@ -182,7 +248,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "**Exercise 1.5**: Write a function that returns the standardized vector of the given vector such that the mean is $0$ and standard deviation is $1$. Mathematically:\n", + "**Exercise 3.5**: Write a function that returns the standardized vector of the given vector such that the mean is $0$ and standard deviation is $1$. Mathematically:\n", "$$\n", "\\forall x_{i}\\in x:\\hspace{1em}x_{i}^{\\prime}=\\frac{x_{i}-\\mu}{\\sigma}\n", "$$" @@ -220,14 +286,14 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Exercise 2" + "### Exercise 4" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "**Exercise 2.1**: Write a function that takes two numpy vectors as an argument and returns `True` if they are orthogonal else returns `False`.\n", + "**Exercise 4.1**: Write a function that takes two numpy vectors as an argument and returns `True` if they are orthogonal else returns `False`.\n", "\n", "*Note: Two vectors are called orthogonal if their inner product is zero.*" ] @@ -262,7 +328,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "**Question 2.2**: Write a function to check whether the given matrix is symmetric or not." + "**Exercise 4.2**: Write a function to check whether the given matrix is symmetric or not." ] }, { @@ -271,7 +337,7 @@ "metadata": {}, "outputs": [], "source": [ - "def is_symmetric(x, y):\n", + "def is_symmetric(x):\n", " # TODO: Finish this function\n", " pass" ] @@ -296,7 +362,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Exercise 3\n" + "### Exercise 5" ] }, { @@ -315,6 +381,7 @@ "For $ t = 1, 2, 3, \\ldots, T $ suppose that\n", "\n", "\n", + "\n", "$$\n", "y_{t} = \\alpha_{0} + \\alpha_{1} y_{t-1}\n", "$$\n", @@ -322,7 +389,7 @@ "where we assume that $ y_0 = 1$, $\\alpha_{0}=5$, and $\\alpha_{1}=1.2$.\n", "\n", "\n", - "**Exercise 3.1**: Use the matrix algebra to solve the above time series equation, and plot the solution.\n", + "Use the matrix algebra to solve the above time series equation, and plot the solution.\n", "\n", "*Hint:*\n", "\n", @@ -389,7 +456,7 @@ "metadata": {}, "outputs": [], "source": [ - "# TODO: Write your code here" + "# TODO: Write your solution here" ] } ], diff --git a/day-02/exercise_set_2_with_solution.ipynb b/day-02/exercise_set_2_with_solution.ipynb index 0df841a..f54637e 100644 --- a/day-02/exercise_set_2_with_solution.ipynb +++ b/day-02/exercise_set_2_with_solution.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Linear Algebra and Probability Distributions Exercises" + "# Python and Linear Algebra Exercises" ] }, { @@ -21,7 +21,7 @@ "metadata": {}, "source": [ "#### Written for the QuantEcon Africa Workshop (July 2023)\n", - "#### Author: [John Stachurski](http://johnstachurski.net/) and [Hengcheng Zhang](https://github.com/HengchengZhang)" + "#### Author: [John Stachurski](http://johnstachurski.net/) , [Hengcheng Zhang](https://github.com/HengchengZhang), and [Smit Lunagariya](https://github.com/Smit-create)" ] }, { @@ -42,6 +42,93 @@ "source": [ "### Exercise 1\n", "\n", + "Complete the following function that returns the number of odd elements in the given list." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def get_odd_num_from_list(nums):\n", + " c = 0\n", + " for num in nums:\n", + " if num%2 == 1:\n", + " c += 1\n", + " return c" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Test the solution\n", + "try:\n", + " assert get_odd_num_from_list([1, 2, 3]) == 2\n", + " assert get_odd_num_from_list(list(range(1, 20))) == 10\n", + " assert get_odd_num_from_list(list(range(0, 20, 2))) == 0\n", + " print(\"Congratulations!\")\n", + "except:\n", + " print(\"Wrong answer, please check your code again.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Exercise 2\n", + "\n", + "Consider the following time-series\n", + "\n", + "$$\n", + " a_{t+1} = (0.5 + r)a_t - br^2a_t\n", + "$$\n", + "\n", + "Assume that $r=0.05$, $b=100$ and $a_0=1.5$.\n", + "\n", + "Generate and plot the sequence $a_0, a_1, ..., a_T$.\n", + "\n", + "Use NumPy arrays to store the sequence $a$.\n", + "\n", + "Use $T=25$." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Solution" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "r = 0.05\n", + "T = 25\n", + "a = np.empty(T+1)\n", + "b = 100\n", + "a[0] = 1.5\n", + "\n", + "for t in range(T):\n", + " a[t+1] = (0.5 + r) * a[t] - b * r**2 * a[t]\n", + "\n", + "plt.plot(a, label='a')\n", + "plt.legend()\n", + "plt.show()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Exercise 3\n", + "\n", "Warm up on NumPy Basics.\n", "\n", "Feel free to refer to the [numpy documentation](https://numpy.org/doc/stable/reference/index.html) for API." @@ -51,7 +138,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "**Exercise 1.1**: Write a function that creates numpy array from the given list/tuple." + "**Exercise 3.1**: Write a function that creates numpy array from the given list/tuple." ] }, { @@ -83,7 +170,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "**Exercise 1.2**: Write a function to return the transpose of the given matrix." + "**Exercise 3.2**: Write a function to return the transpose of the given matrix." ] }, { @@ -114,7 +201,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "**Exercise 1.3**: Write a function to return the inverse of the given matrix." + "**Exercise 3.3**: Write a function to return the inverse of the given matrix." ] }, { @@ -147,7 +234,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "**Exercise 1.4**: Write a function to compute the norm of the vector." + "**Exercise 3.4**: Write a function to compute the norm of the vector." ] }, { @@ -178,7 +265,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "**Exercise 1.5**: Write a function that returns the standardized vector of the given vector such that the mean is $0$ and standard deviation is $1$. Mathematically:\n", + "**Exercise 3.5**: Write a function that returns the standardized vector of the given vector such that the mean is $0$ and standard deviation is $1$. Mathematically:\n", "$$\n", "\\forall x_{i}\\in x:\\hspace{1em}x_{i}^{\\prime}=\\frac{x_{i}-\\mu}{\\sigma}\n", "$$" @@ -216,14 +303,14 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Exercise 2" + "### Exercise 4" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "**Exercise 2.1**: Write a function that takes two numpy vectors as an argument and returns `True` if they are orthogonal else returns `False`.\n", + "**Exercise 4.1**: Write a function that takes two numpy vectors as an argument and returns `True` if they are orthogonal else returns `False`.\n", "\n", "*Note: Two vectors are called orthogonal if their inner product is zero.*" ] @@ -257,7 +344,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "**Exercise 2.2**: Write a function to check whether the given matrix is symmetric or not." + "**Exercise 4.2**: Write a function to check whether the given matrix is symmetric or not." ] }, { @@ -292,7 +379,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Exercise 3\n" + "### Exercise 5" ] }, { @@ -319,7 +406,7 @@ "where we assume that $ y_0 = 1$, $\\alpha_{0}=5$, and $\\alpha_{1}=1.2$.\n", "\n", "\n", - "**Exercise 3.1**: Use the matrix algebra to solve the above time series equation, and plot the solution.\n", + "Use the matrix algebra to solve the above time series equation, and plot the solution.\n", "\n", "*Hint:*\n", "\n",