giving up
This commit is contained in:
1 parent
d1a042206c
commit
4f8830ab5f
4 files changed
+302
-16
No files matched your search
+13
@@ -0,0 +1,13 @@
|
||||
# slide number 1
|
||||
|
||||
we will do it in jupyter notebook as it is better for this purpose
|
||||
|
||||
## what we kinda learn in slide 1
|
||||
|
||||
computer friendly calculation methods. its different to just math.
|
||||
|
||||
it is an approximation method for some of the harder problems that would be hard with math alone
|
||||
|
||||
it gets the job done for some people
|
||||
doesnt for others
|
||||
it idk
|
||||
+171
@@ -0,0 +1,171 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# dont i hate this shit\n",
|
||||
"\n",
|
||||
"im manually translating the slides\n",
|
||||
"\n",
|
||||
"### why numpy and not pure python\n",
|
||||
"\n",
|
||||
"[../0/tutorial2.ipynb#numpy](../0/tutorial2.ipynb#numpy)\n",
|
||||
"\n",
|
||||
"### honestly\n",
|
||||
"\n",
|
||||
"[numpy beginners click here](https://numpy.org/doc/stable/user/absolute_beginners.html)\n",
|
||||
"\n",
|
||||
"## import steps. use for import\n",
|
||||
"\n",
|
||||
"you may need to:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"vscode": {
|
||||
"languageId": "shellscript"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"pip install numpy matplotlib"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import numpy as np\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"%matplotlib inline"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## usage\n",
|
||||
"\n",
|
||||
"make the list in python and then you np.array it and then feed the numpy array to numpy functions\n",
|
||||
"\n",
|
||||
"notice: make it\n",
|
||||
"\n",
|
||||
"1. with same size: `all(len(i) == len(j) for i in pyarray for j in pyarray) == True`\n",
|
||||
"2. all elements have same type `all(type(i) == type(r[0]) for i in r for r in pyarray) == True`\n",
|
||||
"\n",
|
||||
"then you will be able to harness the peak of numpy. Or else goodbye"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"pyarray = [\n",
|
||||
" [1, 2, 3],\n",
|
||||
" [4, 5, 6],\n",
|
||||
"]\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"numpy_array = np.array(pyarray)\n",
|
||||
"\n",
|
||||
"pyarray, numpy_array"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"the 3:11:2 notation in python is called a slice object. numpy (probably) modified its `array.__index__` to yk accommodate to dimensions\n",
|
||||
"\n",
|
||||
"so normally you wouldnt fit more than one thing in that bracket: now you can! pretty great"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"newarr = numpy_array[:,1:3]\n",
|
||||
"newarr"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"kinda cool. normally it would be:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"[i[1:3] for i in pyarray[:]] #uh why so complicated"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"remember this: Python lists count from zero. Everything related to computer memory counts from 0. only Maniacs count from 1.\n",
|
||||
"\n",
|
||||
"also a tip for me actually, for i struggle with matrix rows and columns: `m2d[0,:]` is first Row. `m2d[:, 0]` is first Column. \n",
|
||||
"row goes across. row number x is counted top down. Column goes top down. column number x is counted left to right "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### numpy array (matrix) operations\n",
|
||||
"\n",
|
||||
"the slides (and numpy also) have all the shit: the slice which we just covered, np.transpose `'`, np.matmul `*`, np.multiply `.*`, matrix divide `/` with np.dot and np.linarg.inv, np.divide `./`, concat arrays with np.concatenate np.stack or np.block etc.\n",
|
||||
"\n",
|
||||
"### math functions\n",
|
||||
"\n",
|
||||
"infinitely easier than matlab with python def\n",
|
||||
"\n",
|
||||
"you know exactly what this means:\n",
|
||||
"\n",
|
||||
"```python\n",
|
||||
"def function(x):\n",
|
||||
" return 3*x + 2\n",
|
||||
"```\n",
|
||||
"this WILL work with ndarrays as they do have `__mul__` `__rmul__` and `__add__`\n",
|
||||
"\n",
|
||||
"as opposed to matlab with its cumbersome ahh syms\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"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.12.5"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
Reference in new issue
Block a user