Skip to content

Instantly share code, notes, and snippets.

@mwy912
Created October 15, 2020 20:19
Show Gist options
  • Save mwy912/24b08a8cc2f127f89364974ffafde2ae to your computer and use it in GitHub Desktop.
Save mwy912/24b08a8cc2f127f89364974ffafde2ae to your computer and use it in GitHub Desktop.
Created on Skills Network Labs
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<center>\n",
" <img src=\"https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/Logos/organization_logo/organization_logo.png\" width=\"300\" alt=\"cognitiveclass.ai logo\" />\n",
"</center>\n",
"\n",
"# 1D Numpy in Python\n",
"\n",
"Estimated time needed: **30** minutes\n",
"\n",
"## Objectives\n",
"\n",
"After completing this lab you will be able to:\n",
"\n",
"- Import and use `numpy` library\n",
"- Perform operations with `numpy`\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2>Table of Contents</h2>\n",
"<div class=\"alert alert-block alert-info\" style=\"margin-top: 20px\">\n",
" <ul>\n",
" <li><a href=\"pre\">Preparation</a></li>\n",
" <li>\n",
" <a href=\"numpy\">What is Numpy?</a>\n",
" <ul>\n",
" <li><a href=\"type\">Type</a></li>\n",
" <li><a href=\"val\">Assign Value</a></li>\n",
" <li><a href=\"slice\">Slicing</a></li>\n",
" <li><a href=\"list\">Assign Value with List</a></li>\n",
" <li><a href=\"other\">Other Attributes</a></li>\n",
" </ul>\n",
" </li>\n",
" <li>\n",
" <a href=\"op\">Numpy Array Operations</a>\n",
" <ul>\n",
" <li><a href=\"add\">Array Addition</a></li>\n",
" <li><a href=\"multi\">Array Multiplication</a></li>\n",
" <li><a href=\"prod\">Product of Two Numpy Arrays</a></li>\n",
" <li><a href=\"dot\">Dot Product</a></li>\n",
" <li><a href=\"cons\">Adding Constant to a Numpy Array</a></li>\n",
" </ul>\n",
" </li>\n",
" <li><a href=\"math\">Mathematical Functions</a></li>\n",
" <li><a href=\"lin\">Linspace</a></li>\n",
" </ul>\n",
"\n",
"</div>\n",
"\n",
"<hr>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2 id=\"pre\">Preparation</h2>\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"# Import the libraries\n",
"\n",
"import time \n",
"import sys\n",
"import numpy as np \n",
"\n",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline "
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"# Plotting functions\n",
"\n",
"def Plotvec1(u, z, v):\n",
" \n",
" ax = plt.axes()\n",
" ax.arrow(0, 0, *u, head_width=0.05, color='r', head_length=0.1)\n",
" plt.text(*(u + 0.1), 'u')\n",
" \n",
" ax.arrow(0, 0, *v, head_width=0.05, color='b', head_length=0.1)\n",
" plt.text(*(v + 0.1), 'v')\n",
" ax.arrow(0, 0, *z, head_width=0.05, head_length=0.1)\n",
" plt.text(*(z + 0.1), 'z')\n",
" plt.ylim(-2, 2)\n",
" plt.xlim(-2, 2)\n",
"\n",
"def Plotvec2(a,b):\n",
" ax = plt.axes()\n",
" ax.arrow(0, 0, *a, head_width=0.05, color ='r', head_length=0.1)\n",
" plt.text(*(a + 0.1), 'a')\n",
" ax.arrow(0, 0, *b, head_width=0.05, color ='b', head_length=0.1)\n",
" plt.text(*(b + 0.1), 'b')\n",
" plt.ylim(-2, 2)\n",
" plt.xlim(-2, 2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Create a Python List as follows:\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"# Create a python list\n",
"\n",
"a = [\"0\", 1, \"two\", \"3\", 4]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can access the data via an index:\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/PY0101EN/Chapter%205/Images/NumOneList.png\" width=\"660\" />\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can access each element using a square bracket as follows: \n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"a[0]: 0\n",
"a[1]: 1\n",
"a[2]: two\n",
"a[3]: 3\n",
"a[4]: 4\n"
]
}
],
"source": [
"# Print each element\n",
"\n",
"print(\"a[0]:\", a[0])\n",
"print(\"a[1]:\", a[1])\n",
"print(\"a[2]:\", a[2])\n",
"print(\"a[3]:\", a[3])\n",
"print(\"a[4]:\", a[4])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2 id=\"numpy\">What is Numpy?</h2>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A numpy array is similar to a list. It's usually fixed in size and each element is of the same type. We can cast a list to a numpy array by first importing numpy: \n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"# import numpy library\n",
"\n",
"import numpy as np "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" We then cast the list as follows:\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0, 1, 2, 3, 4])"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Create a numpy array\n",
"\n",
"a = np.array([0, 1, 2, 3, 4])\n",
"a"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Each element is of the same type, in this case integers: \n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/PY0101EN/Chapter%205/Images/NumOneNp.png\" width=\"500\" />\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" As with lists, we can access each element via a square bracket:\n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"a[0]: 0\n",
"a[1]: 1\n",
"a[2]: 2\n",
"a[3]: 3\n",
"a[4]: 4\n"
]
}
],
"source": [
"# Print each element\n",
"\n",
"print(\"a[0]:\", a[0])\n",
"print(\"a[1]:\", a[1])\n",
"print(\"a[2]:\", a[2])\n",
"print(\"a[3]:\", a[3])\n",
"print(\"a[4]:\", a[4])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3 id=\"type\">Type</h3>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If we check the type of the array we get <b>numpy.ndarray</b>:\n"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"numpy.ndarray"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Check the type of the array\n",
"\n",
"type(a)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"As numpy arrays contain data of the same type, we can use the attribute \"dtype\" to obtain the Data-type of the array’s elements. In this case a 64-bit integer: \n"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"dtype('int64')"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Check the type of the values stored in numpy array\n",
"\n",
"a.dtype"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can create a numpy array with real numbers:\n"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"# Create a numpy array\n",
"\n",
"b = np.array([3.1, 11.02, 6.2, 213.2, 5.2])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"When we check the type of the array we get <b>numpy.ndarray</b>:\n"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"numpy.ndarray"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Check the type of array\n",
"\n",
"type(b)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If we examine the attribute <code>dtype</code> we see float 64, as the elements are not integers: \n"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"dtype('float64')"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Check the value type\n",
"\n",
"b.dtype"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3 id=\"val\">Assign value</h3>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can change the value of the array, consider the array <code>c</code>:\n"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([20, 1, 2, 3, 4])"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Create numpy array\n",
"\n",
"c = np.array([20, 1, 2, 3, 4])\n",
"c"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can change the first element of the array to 100 as follows:\n"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([100, 1, 2, 3, 4])"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Assign the first element to 100\n",
"\n",
"c[0] = 100\n",
"c"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can change the 5th element of the array to 0 as follows:\n"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([100, 1, 2, 3, 0])"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Assign the 5th element to 0\n",
"\n",
"c[4] = 0\n",
"c"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3 id=\"slice\">Slicing</h3>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Like lists, we can slice the numpy array, and we can select the elements from 1 to 3 and assign it to a new numpy array <code>d</code> as follows:\n"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([1, 2, 3])"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Slicing the numpy array\n",
"\n",
"d = c[1:4]\n",
"d"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can assign the corresponding indexes to new values as follows: \n"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([100, 1, 2, 300, 400])"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Set the fourth element and fifth element to 300 and 400\n",
"\n",
"c[3:5] = 300, 400\n",
"c"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3 id=\"list\">Assign Value with List</h3>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Similarly, we can use a list to select a specific index.\n",
"The list ' select ' contains several values:\n"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
"# Create the index list\n",
"\n",
"select = [0, 2, 3]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can use the list as an argument in the brackets. The output is the elements corresponding to the particular index:\n"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([100, 2, 300])"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Use List to select elements\n",
"\n",
"d = c[select]\n",
"d"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can assign the specified elements to a new value. For example, we can assign the values to 100 000 as follows:\n"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([100000, 1, 100000, 100000, 400])"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Assign the specified elements to new value\n",
"\n",
"c[select] = 100000\n",
"c"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3 id=\"other\">Other Attributes</h3>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's review some basic array attributes using the array <code>a</code>:\n"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0, 1, 2, 3, 4])"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Create a numpy array\n",
"\n",
"a = np.array([0, 1, 2, 3, 4])\n",
"a"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The attribute <code>size</code> is the number of elements in the array:\n"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"5"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Get the size of numpy array\n",
"\n",
"a.size"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The next two attributes will make more sense when we get to higher dimensions but let's review them. The attribute <code>ndim</code> represents the number of array dimensions or the rank of the array, in this case, one:\n"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Get the number of dimensions of numpy array\n",
"\n",
"a.ndim"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The attribute <code>shape</code> is a tuple of integers indicating the size of the array in each dimension:\n"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(5,)"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Get the shape/size of numpy array\n",
"\n",
"a.shape"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [],
"source": [
"# Create a numpy array\n",
"\n",
"a = np.array([1, -1, 1, -1])"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.0"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Get the mean of numpy array\n",
"\n",
"mean = a.mean()\n",
"mean"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1.0"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Get the standard deviation of numpy array\n",
"\n",
"standard_deviation=a.std()\n",
"standard_deviation"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([-1, 2, 3, 4, 5])"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Create a numpy array\n",
"\n",
"b = np.array([-1, 2, 3, 4, 5])\n",
"b"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"5"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Get the biggest value in the numpy array\n",
"\n",
"max_b = b.max()\n",
"max_b"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"-1"
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Get the smallest value in the numpy array\n",
"\n",
"min_b = b.min()\n",
"min_b"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2 id=\"op\">Numpy Array Operations</h2>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3 id=\"add\">Array Addition</h3>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Consider the numpy array <code>u</code>:\n"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([1, 0])"
]
},
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"u = np.array([1, 0])\n",
"u"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Consider the numpy array <code>v</code>:\n"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0, 1])"
]
},
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"v = np.array([0, 1])\n",
"v"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can add the two arrays and assign it to z:\n"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([1, 1])"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Numpy Array Addition\n",
"\n",
"z = u + v\n",
"z"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" The operation is equivalent to vector addition:\n"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAAD8CAYAAAB3u9PLAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAYDklEQVR4nO3deZBdZbnv8e/TGRhCkCEJZCAQi3gheD0RW4ajUkTRCzlq9BRo1FLLKUI5FrcsuHIuUrcKC714LClEjCKDVyYZIySMCgHLYDqRQEgQGkxM6EBCQkI4Ycjw3D96mdMn7E53Z6/utbv7+6na1Wvt9e71PvXS9C/vmnZkJpIkNVVdgCSpMRgIkiTAQJAkFQwESRJgIEiSCgaCJAkoIRAi4rCI+ENELI+IJyLiWzXaRERcEhGtEfFYRBxbb7+SpHINLWEf24D/mZmLI2IksCgi7s3MZR3anAZMLl7HAz8rfkqSGkTd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G7qh7LbmmE8Sz6vwJYnpn/3kmzno9nlWfKdzkj3kr78a5Hi9flxfvjgLm7nDl/ivYrK86roM6P0568rwMvAHfvWiftV3wsKV5PNGqdDTKeBwP3A08XPw9qpPGsNT7AmcCZxXLQ/gVQzwCPs5srzyqs8evFuC2h/YKNf+7rGos6rgPWAFuL380vNdpYdrPOyscTeC/th38e6/A3c3q94+mjKyRJQAMdMpIkVctAkCQBBoIkqWAgSJIAA0GSVDAQJEmAgSBJKvx/c5+2+a6YW2wAAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# Plot numpy arrays\n",
"\n",
"Plotvec1(u, z, v)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3 id=\"multi\">Array Multiplication</h3>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Consider the vector numpy array <code>y</code>:\n"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([1, 2])"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Create a numpy array\n",
"\n",
"y = np.array([1, 2])\n",
"y"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can multiply every element in the array by 2:\n"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([2, 4])"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Numpy Array Multiplication\n",
"\n",
"z = 2 * y\n",
"z"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" This is equivalent to multiplying a vector by a scaler: \n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3 id=\"prod\">Product of Two Numpy Arrays</h3>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Consider the following array <code>u</code>:\n"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([1, 2])"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Create a numpy array\n",
"\n",
"u = np.array([1, 2])\n",
"u"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Consider the following array <code>v</code>:\n"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([3, 2])"
]
},
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Create a numpy array\n",
"\n",
"v = np.array([3, 2])\n",
"v"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" The product of the two numpy arrays <code>u</code> and <code>v</code> is given by:\n"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([3, 4])"
]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Calculate the production of two numpy arrays\n",
"\n",
"z = u * v\n",
"z"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3 id=\"dot\">Dot Product</h3>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The dot product of the two numpy arrays <code>u</code> and <code>v</code> is given by:\n"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"7"
]
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Calculate the dot product\n",
"\n",
"np.dot(u, v)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3 id=\"cons\">Adding Constant to a Numpy Array</h3>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Consider the following array: \n"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 1, 2, 3, -1])"
]
},
"execution_count": 41,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Create a constant to numpy array\n",
"\n",
"u = np.array([1, 2, 3, -1]) \n",
"u"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Adding the constant 1 to each element in the array:\n"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([2, 3, 4, 0])"
]
},
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Add the constant to array\n",
"\n",
"u + 1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" The process is summarised in the following animation:\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"https://s3-api.us-geo.objectstorage.softlayer.net/cf-courses-data/CognitiveClass/PY0101EN/Chapter%205/Images/NumOneAdd.gif\" width=\"500\" />\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2 id=\"math\">Mathematical Functions</h2>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" We can access the value of <code>pi</code> in numpy as follows :\n"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3.141592653589793"
]
},
"execution_count": 43,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# The value of pi\n",
"\n",
"np.pi"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" We can create the following numpy array in Radians:\n"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {},
"outputs": [],
"source": [
"# Create the numpy array in radians\n",
"\n",
"x = np.array([0, np.pi/2 , np.pi])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can apply the function <code>sin</code> to the array <code>x</code> and assign the values to the array <code>y</code>; this applies the sine function to each element in the array: \n"
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0.0000000e+00, 1.0000000e+00, 1.2246468e-16])"
]
},
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Calculate the sin of each elements\n",
"\n",
"y = np.sin(x)\n",
"y"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2 id=\"lin\">Linspace</h2>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" A useful function for plotting mathematical functions is <code>linspace</code>. Linspace returns evenly spaced numbers over a specified interval. We specify the starting point of the sequence and the ending point of the sequence. The parameter \"num\" indicates the Number of samples to generate, in this case 5:\n"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([-2., -1., 0., 1., 2.])"
]
},
"execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Makeup a numpy array within [-2, 2] and 5 elements\n",
"\n",
"np.linspace(-2, 2, num=5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If we change the parameter <code>num</code> to 9, we get 9 evenly spaced numbers over the interval from -2 to 2: \n"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([-2. , -1.5, -1. , -0.5, 0. , 0.5, 1. , 1.5, 2. ])"
]
},
"execution_count": 47,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Makeup a numpy array within [-2, 2] and 9 elements\n",
"\n",
"np.linspace(-2, 2, num=9)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can use the function <code>linspace</code> to generate 100 evenly spaced samples from the interval 0 to 2π: \n"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {},
"outputs": [],
"source": [
"# Makeup a numpy array within [0, 2π] and 100 elements \n",
"\n",
"x = np.linspace(0, 2*np.pi, num=100)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can apply the sine function to each element in the array <code>x</code> and assign it to the array <code>y</code>: \n"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {},
"outputs": [],
"source": [
"# Calculate the sine of x list\n",
"\n",
"y = np.sin(x)"
]
},
{
"cell_type": "code",
"execution_count": 50,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x7ff350d24400>]"
]
},
"execution_count": 50,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAD4CAYAAADhNOGaAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAur0lEQVR4nO3dd3yV9fn/8deVRSAkzARCAgTIgACyIoIDZQqoRa21YrX4ayu1guKoLVVrbWvrqrbVIoqAYh04caKgDGXICMieIRASZliBELKv3x85+E1jgIRzkvuM6/l4nEfOvc79DiNXPvf9uT8fUVWMMcYEriCnAxhjjHGWFQJjjAlwVgiMMSbAWSEwxpgAZ4XAGGMCXIjTAc5Hy5YtNSEhwekYxhjjU1atWnVIVaOrrvfJQpCQkEB6errTMYwxxqeISFZ16+3SkDHGBDgrBMYYE+CsEBhjTICzQmCMMQHOCoExxgQ4jxQCEZkuIgdFZMMZtouIPCciGSKyTkR6V9o2XES2urZN9EQeY4wxNeepFsGrwPCzbB8BJLleY4HJACISDExybU8FRotIqocyGWOMqQGPPEegqt+ISMJZdhkFvKYVY14vE5GmIhILJAAZqpoJICIzXftu8kQuUzuFJWVk5p5k+8ETHDlZTFFpOUUl5YSGCDGR4cRENiChRQRtmzdERJyOa4zxkPp6oCwOyK60nONaV936i6r7ABEZS0Vrgnbt2tVNygBTXFpOetYRFm7NZeHWg2w/mE9Npqdo2TiMXu2a0a9jC66+IJZWUeF1H9YYU2fqqxBU9+ujnmX9D1eqTgGmAKSlpdlsOm7IPlLA68uyeDs9m2MFJYQGCxd1aMGIbrEktWpMYkx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LUSC8xw9UALAt5RVZ/sgunDWgGzKn6nIAR4U1W/cDZSrd0FvOH6hTQT+H8O5wmc7qPGGGOqF0iXhowxxlTDCoExxgQ4KwTGGBPgrBAYY0yAs0JgjDEBzgqBMcYEOCsExhgT4P4/qSdBaQEiSUoAAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# Plot the result\n",
"\n",
"plt.plot(x, y)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2 id=\"quiz\">Quiz on 1D Numpy Array</h2>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Implement the following vector subtraction in numpy: u-v\n"
]
},
{
"cell_type": "code",
"execution_count": 51,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 1, -1])"
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Write your code below and press Shift+Enter to execute\n",
"\n",
"u = np.array([1, 0])\n",
"v = np.array([0, 1])\n",
"\n",
"z = u-v\n",
"z"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Double-click **here** for the solution.\n",
"\n",
"<!-- Your answer is below:\n",
"u - v\n",
"-->\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Multiply the numpy array z with -2:\n"
]
},
{
"cell_type": "code",
"execution_count": 52,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([-4, -8])"
]
},
"execution_count": 52,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Write your code below and press Shift+Enter to execute\n",
"\n",
"z = np.array([2, 4])\n",
"\n",
"z * -2"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Double-click **here** for the solution.\n",
"\n",
"<!-- Your answer is below:\n",
"-2 * z\n",
"-->\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Consider the list <code>[1, 2, 3, 4, 5]</code> and <code>[1, 0, 1, 0, 1]</code>, and cast both lists to a numpy array then multiply them together:\n"
]
},
{
"cell_type": "code",
"execution_count": 53,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([1, 0, 3, 0, 5])"
]
},
"execution_count": 53,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Write your code below and press Shift+Enter to execute\n",
"\n",
"list1 = [1,2,3,4,5]\n",
"list2 = [1,0,1,0,1]\n",
"\n",
"a = np.array(list1)\n",
"b = np.array(list2)\n",
"\n",
"a*b"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Double-click **here** for the solution.\n",
"\n",
"<!-- Your answer is below:\n",
"a = np.array([1, 2, 3, 4, 5])\n",
"b = np.array([1, 0, 1, 0, 1])\n",
"a * b\n",
"-->\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Convert the list <code>[-1, 1]</code> and <code>[1, 1]</code> to numpy arrays <code>a</code> and <code>b</code>. Then, plot the arrays as vectors using the fuction <code>Plotvec2</code> and find the dot product:\n"
]
},
{
"cell_type": "code",
"execution_count": 57,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0"
]
},
"execution_count": 57,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAAD8CAYAAAB3u9PLAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAaRElEQVR4nO3deZxV9X3/8dd7ADUgBJRFVjUNiStuE5ZIEtJEC9RGbdVos/AwaalG09j6aP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UdJhkpQtjyb9v99WwRpbq+ixbJVqGM+s/x8BqyLiB800a/t4FnmkvMkR8bWk/V1PZF/Ts8eHAHObHDl/mnRmxVUF1Hk2KXnfBF4E5jWtk3TGx9Lsa2W11lkl43ko8ACwJvt+SDWNZ6nxAS4CLsqWRboB1DPAcvZx5lmBNV6ajdtS0gkbH610jVkdM4FNwK7sb/PL1TaWrayz8PEExpN2/yxr9J45udzx9NQVZmYGVNEuIzMzK5YDwczMAAeCmZllHAhmZgY4EMzMLONAMDMzwIFgZmaZ/w/tOhx1vepY5gAAAABJRU5ErkJggg==\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# Write your code below and press Shift+Enter to execute\n",
"\n",
"a = np.array([-1,1])\n",
"b = np.array([1,1])\n",
"\n",
"Plotvec2(a,b)\n",
"\n",
"np.dot(a,b)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Double-click **here** for the solution.\n",
"\n",
"<!-- Your answer is below:\n",
"a = np.array([-1, 1])\n",
"b = np.array([1, 1])\n",
"Plotvec2(a, b)\n",
"print(\"The dot product is\", np.dot(a,b))\n",
"-->\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Convert the list <code>[1, 0]</code> and <code>[0, 1]</code> to numpy arrays <code>a</code> and <code>b</code>. Then, plot the arrays as vectors using the function <code>Plotvec2</code> and find the dot product:\n"
]
},
{
"cell_type": "code",
"execution_count": 58,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"the dot product = 0\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAAD8CAYAAAB3u9PLAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMA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r9dx/VeM5lfIBNwIP07rdZD3x/Eda4Afi/o/pbnFLHfwSuBXbPsH6kYzmPOkc+nsAK4No2fSG9RwcN/Le5aPYQ6gx5DEZV7a2q/cPs83TMsc6Rj2fr7942fS9w85D7P5W5jM9m4L7qeRK4OMmKRVbjolBVO4CXT9Fk1GMJzKnOkauqI1X1dJt+hd4VnCunNZv3eC6aQJjmc/SSbbp+j8GYPgiLRQGPJNnZHsexGC2G8XxXVR2B3h85cNkM7UYxnnMZn1GP4Vz7vyHJs0keTHLNcEqbt1GP5XwsmvFM8h7gN4DvT1s17/Hs8llGsxr2YzBO11zqnIMbq+pwksvo3aexr/2fR2c6qHPk4zmPzSz4ePYxl/EZyhiewlz6fxp4d1W9mmQT8C1gzUIXdhpGPZZztWjGM8kFwF8Df1RVP52+us9HTjmeQw2EOkMegzFbnXPcxuH2fjTJVnq79p1+gXVQ58jHM8mPkqyoqiNtd/boDNtY8PHsYy7jM+pHs8za/9QviqranuRrSS6tqsX2kLZRj+WcLJbxTLKEXhjcX1V/06fJvMdz0Rwyyln0GIwky5Jc+MtpeifMF+NTWxfDeG4DtrTpLcCb9mxGOJ5zGZ9twGfaFR3rgeO/PAQ2JLPWmOTyJGnT6+j9u//xEGucq1GP5ZwshvFs/f85sLeq/nSGZvMfz1GeKZ92RvwAveNdz7TX3W35FcD2aWfO/5HelRV3jqDOj9NL3n8BfgQ8PL1Oeld8PNteexZrnYtkPN8JfBd4vr1fspjGs9/4AJ8HPt+mQ+8HoP4J+AGnuPJshDXe3sbtWXoXbPyHYdfY6ngAOAL8vP1t/v5iG8s51jny8QQ+RO/wz64p35mbBh1PH10hSQIW0SEjSdJoGQiSJMBAkCQ1BoIkCTAQJEmNgSBJAgwESVLz/wGswKsYaRlXhwAAAABJRU5ErkJggg==\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# Write your code below and press Shift+Enter to execute\n",
"\n",
"\n",
"a = np.array([1,0])\n",
"b = np.array([0,1])\n",
"\n",
"Plotvec2(a,b)\n",
"\n",
"print(\"the dot product = \",np.dot(a,b))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Double-click **here** for the solution.\n",
"\n",
"<!-- \n",
"a = np.array([1, 0])\n",
"b = np.array([0, 1])\n",
"Plotvec2(a, b)\n",
"print(\"The dot product is\", np.dot(a, b))\n",
" -->\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Convert the list <code>[1, 1]</code> and <code>[0, 1]</code> to numpy arrays <code>a</code> and <code>b</code>. Then plot the arrays as vectors using the fuction <code>Plotvec2</code> and find the dot product:\n"
]
},
{
"cell_type": "code",
"execution_count": 59,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"the dot product = 1\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYQAAAD8CAYAAAB3u9PLAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAAWK0lEQVR4nO3de4xd5Xnv8e+DMeVeLuZisA1EsUogNSkZGXOgEVECMlYVkwpOITeURJoGhbaoR9XhBIW2R6qU5lStahEg0wYCFYE0JYATDMZOSx2nmDJ2sA0YsEMNHsbFxgYDMQRsnvPHWtTTYY9nz+w1e+2Z+X6k0ay117vX++j1eH7zrtuOzESSpAPqLkCS1BkMBEkSYCBIkkoGgiQJMBAkSSUDQZIEVBAIETEzIv4lIjZExJMR8UcN2kRELIqITRGxLiLObrVfSVK1DqxgH3uA/5WZayLiCGB1RCzLzKcGtLkYmF1+nQPcVH6XJHWIlmcImbk1M9eUy68DG4CTBzVbCNyehVXAURExvdW+JUnVqWKG8F8i4lTgt4BHB206GdgyYL2vfG1rg310A90Ahx122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ICLObE9pI1b3WI5Ex4xnRJwK/Bbw6KBNIx7PKp9lNKx2PwZjtJqpswnnZWZ/RBxPcZ/G0+VfHpWpoM7ax3MEuxnz8WygmfFpyxjuRzP9rwFOycw3ImIBcC8we6wLG4W6x7JZHTOeEXE4cDdwTWa+Nnhzg7fsdzzbGgg5Th6DMVydTe6jv/y+LSLuoZjaV/oLrII6ax/PiHgpIqZn5tZyOrttiH2M+Xg20Mz41P1olmH7H/iLIjOXRMSNETEtMzvtIW11j2VTOmU8I2IqRRjckZk/bNBkxOPZMYeMYgI9BiMiDouII95bpjhh3olPbe2E8VwMXFkuXwm8b2ZT43g2Mz6LgS+UV3TMA3a9dwisTYatMSJOjIgol+dS/L/f0cYam1X3WDalE8az7P87wIbM/Oshmo18POs8Uz7ojPgmiuNdj5dfN5evnwQsGXTm/FmKKyuuq6HOT1Mk76+Al4Clg+ukuOJjbfn1ZKfW2SHjeSzwE2Bj+f2YThrPRuMDfAX4SrkcFB8A9QtgPfu58qzGGq8ux20txQUb/6PdNZZ13AlsBd4pfza/3Glj2WSdtY8ncD7F4Z91A35nLmh1PH10hSQJ6KBDRpKkehkIkiTAQJAklQwESRJgIEiSSgaCJAkwECRJpf8PUFrfmFkkuEAAAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# Write your code below and press Shift+Enter to execute\n",
"\n",
"\n",
"a = np.array([1,1])\n",
"b = np.array([0,1])\n",
"\n",
"Plotvec2(a,b)\n",
"\n",
"print(\"the dot product = \",np.dot(a,b))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Double-click **here** for the solution.\n",
"\n",
"<!-- \n",
"a = np.array([1, 1])\n",
"b = np.array([0, 1])\n",
"Plotvec2(a, b)\n",
"print(\"The dot product is\", np.dot(a, b))\n",
"print(\"The dot product is\", np.dot(a, b))\n",
" -->\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Why are the results of the dot product for <code>[-1, 1]</code> and <code>[1, 1]</code> and the dot product for <code>[1, 0]</code> and <code>[0, 1]</code> zero, but not zero for the dot product for <code>[1, 1]</code> and <code>[0, 1]</code>? <p><i>Hint: Study the corresponding figures, pay attention to the direction the arrows are pointing to.</i></p>\n"
]
},
{
"cell_type": "code",
"execution_count": 60,
"metadata": {},
"outputs": [],
"source": [
"# Write your code below and press Shift+Enter to execute\n",
"\n",
"#The two vectors are not at right angles!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Double-click **here** for the solution.\n",
"\n",
"<!-- \n",
"The vectors used for question 4 and 5 are perpendicular. As a result, the dot product is zero. \n",
"-->\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<hr>\n",
"<h2>The last exercise!</h2>\n",
"<p>Congratulations, you have completed your first lesson and hands-on lab in Python. However, there is one more thing you need to do. The Data Science community encourages sharing work. The best way to share and showcase your work is to share it on GitHub. By sharing your notebook on GitHub you are not only building your reputation with fellow data scientists, but you can also show it off when applying for a job. Even though this was your first piece of work, it is never too early to start building good habits. So, please read and follow <a href=\"https://cognitiveclass.ai/blog/data-scientists-stand-out-by-sharing-your-notebooks/\" target=\"_blank\">this article</a> to learn how to share your work.\n",
"<hr>\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Author\n",
"\n",
"<a href=\"https://www.linkedin.com/in/joseph-s-50398b136/\" target=\"_blank\">Joseph Santarcangelo</a>\n",
"\n",
"## Other contributors\n",
"\n",
"<a href=\"www.linkedin.com/in/jiahui-mavis-zhou-a4537814a\">Mavis Zhou</a>\n",
"\n",
"## Change Log\n",
"\n",
"| Date (YYYY-MM-DD) | Version | Changed By | Change Description |\n",
"| ----------------- | ------- | ---------- | ---------------------------------- |\n",
"| 2020-08-26 | 2.0 | Lavanya | Moved lab to course repo in GitLab |\n",
"| | | | |\n",
"| | | | |\n",
"\n",
"<hr/>\n",
"\n",
"## <h3 align=\"center\"> © IBM Corporation 2020. All rights reserved. <h3/>\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python",
"language": "python",
"name": "conda-env-python-py"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.11"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment