338 lines
9.0 KiB
Plaintext
Executable File
338 lines
9.0 KiB
Plaintext
Executable File
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Getting Started\n",
|
|
"\n",
|
|
"**Markdown** is a method to write documentations and even embed `HTML` and `Latex` formulas.\n",
|
|
"\n",
|
|
"### Jupyter tutorial\n",
|
|
"\n",
|
|
"[![Jupyter Youtube Tutorial](https://img.youtube.com/vi/CwFq3YDU6_Y/0.jpg)](https://www.youtube.com/watch?v=CwFq3YDU6_Y?rel=0&showinfo=0)\n",
|
|
"\n",
|
|
"\n",
|
|
"### Bayesian Rule\n",
|
|
"$$P(A \\mid B) = \\frac{P(B \\mid A)P(A)}{P(B)}$$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Coding and magic commands"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"[1, 8, 27, 64, 125, 216, 343]"
|
|
]
|
|
},
|
|
"execution_count": 1,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"[x**3 for x in range(1,8)]"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"application/json": {
|
|
"cell": {
|
|
"!": "OSMagics",
|
|
"HTML": "Other",
|
|
"SVG": "Other",
|
|
"bash": "Other",
|
|
"capture": "ExecutionMagics",
|
|
"debug": "ExecutionMagics",
|
|
"file": "Other",
|
|
"html": "DisplayMagics",
|
|
"javascript": "DisplayMagics",
|
|
"js": "DisplayMagics",
|
|
"latex": "DisplayMagics",
|
|
"markdown": "DisplayMagics",
|
|
"perl": "Other",
|
|
"prun": "ExecutionMagics",
|
|
"pypy": "Other",
|
|
"python": "Other",
|
|
"python2": "Other",
|
|
"python3": "Other",
|
|
"ruby": "Other",
|
|
"script": "ScriptMagics",
|
|
"sh": "Other",
|
|
"svg": "DisplayMagics",
|
|
"sx": "OSMagics",
|
|
"system": "OSMagics",
|
|
"time": "ExecutionMagics",
|
|
"timeit": "ExecutionMagics",
|
|
"writefile": "OSMagics"
|
|
},
|
|
"line": {
|
|
"alias": "OSMagics",
|
|
"alias_magic": "BasicMagics",
|
|
"autoawait": "AsyncMagics",
|
|
"autocall": "AutoMagics",
|
|
"automagic": "AutoMagics",
|
|
"autosave": "KernelMagics",
|
|
"bookmark": "OSMagics",
|
|
"cat": "Other",
|
|
"cd": "OSMagics",
|
|
"clear": "KernelMagics",
|
|
"colors": "BasicMagics",
|
|
"conda": "PackagingMagics",
|
|
"config": "ConfigMagics",
|
|
"connect_info": "KernelMagics",
|
|
"cp": "Other",
|
|
"debug": "ExecutionMagics",
|
|
"dhist": "OSMagics",
|
|
"dirs": "OSMagics",
|
|
"doctest_mode": "BasicMagics",
|
|
"ed": "Other",
|
|
"edit": "KernelMagics",
|
|
"env": "OSMagics",
|
|
"gui": "BasicMagics",
|
|
"hist": "Other",
|
|
"history": "HistoryMagics",
|
|
"killbgscripts": "ScriptMagics",
|
|
"ldir": "Other",
|
|
"less": "KernelMagics",
|
|
"lf": "Other",
|
|
"lk": "Other",
|
|
"ll": "Other",
|
|
"load": "CodeMagics",
|
|
"load_ext": "ExtensionMagics",
|
|
"loadpy": "CodeMagics",
|
|
"logoff": "LoggingMagics",
|
|
"logon": "LoggingMagics",
|
|
"logstart": "LoggingMagics",
|
|
"logstate": "LoggingMagics",
|
|
"logstop": "LoggingMagics",
|
|
"ls": "Other",
|
|
"lsmagic": "BasicMagics",
|
|
"lx": "Other",
|
|
"macro": "ExecutionMagics",
|
|
"magic": "BasicMagics",
|
|
"man": "KernelMagics",
|
|
"matplotlib": "PylabMagics",
|
|
"mkdir": "Other",
|
|
"more": "KernelMagics",
|
|
"mv": "Other",
|
|
"notebook": "BasicMagics",
|
|
"page": "BasicMagics",
|
|
"pastebin": "CodeMagics",
|
|
"pdb": "ExecutionMagics",
|
|
"pdef": "NamespaceMagics",
|
|
"pdoc": "NamespaceMagics",
|
|
"pfile": "NamespaceMagics",
|
|
"pinfo": "NamespaceMagics",
|
|
"pinfo2": "NamespaceMagics",
|
|
"pip": "PackagingMagics",
|
|
"popd": "OSMagics",
|
|
"pprint": "BasicMagics",
|
|
"precision": "BasicMagics",
|
|
"prun": "ExecutionMagics",
|
|
"psearch": "NamespaceMagics",
|
|
"psource": "NamespaceMagics",
|
|
"pushd": "OSMagics",
|
|
"pwd": "OSMagics",
|
|
"pycat": "OSMagics",
|
|
"pylab": "PylabMagics",
|
|
"qtconsole": "KernelMagics",
|
|
"quickref": "BasicMagics",
|
|
"recall": "HistoryMagics",
|
|
"rehashx": "OSMagics",
|
|
"reload_ext": "ExtensionMagics",
|
|
"rep": "Other",
|
|
"rerun": "HistoryMagics",
|
|
"reset": "NamespaceMagics",
|
|
"reset_selective": "NamespaceMagics",
|
|
"rm": "Other",
|
|
"rmdir": "Other",
|
|
"run": "ExecutionMagics",
|
|
"save": "CodeMagics",
|
|
"sc": "OSMagics",
|
|
"set_env": "OSMagics",
|
|
"store": "StoreMagics",
|
|
"sx": "OSMagics",
|
|
"system": "OSMagics",
|
|
"tb": "ExecutionMagics",
|
|
"time": "ExecutionMagics",
|
|
"timeit": "ExecutionMagics",
|
|
"unalias": "OSMagics",
|
|
"unload_ext": "ExtensionMagics",
|
|
"who": "NamespaceMagics",
|
|
"who_ls": "NamespaceMagics",
|
|
"whos": "NamespaceMagics",
|
|
"xdel": "NamespaceMagics",
|
|
"xmode": "BasicMagics"
|
|
}
|
|
},
|
|
"text/plain": [
|
|
"Available line magics:\n",
|
|
"%alias %alias_magic %autoawait %autocall %automagic %autosave %bookmark %cat %cd %clear %colors %conda %config %connect_info %cp %debug %dhist %dirs %doctest_mode %ed %edit %env %gui %hist %history %killbgscripts %ldir %less %lf %lk %ll %load %load_ext %loadpy %logoff %logon %logstart %logstate %logstop %ls %lsmagic %lx %macro %magic %man %matplotlib %mkdir %more %mv %notebook %page %pastebin %pdb %pdef %pdoc %pfile %pinfo %pinfo2 %pip %popd %pprint %precision %prun %psearch %psource %pushd %pwd %pycat %pylab %qtconsole %quickref %recall %rehashx %reload_ext %rep %rerun %reset %reset_selective %rm %rmdir %run %save %sc %set_env %store %sx %system %tb %time %timeit %unalias %unload_ext %who %who_ls %whos %xdel %xmode\n",
|
|
"\n",
|
|
"Available cell magics:\n",
|
|
"%%! %%HTML %%SVG %%bash %%capture %%debug %%file %%html %%javascript %%js %%latex %%markdown %%perl %%prun %%pypy %%python %%python2 %%python3 %%ruby %%script %%sh %%svg %%sx %%system %%time %%timeit %%writefile\n",
|
|
"\n",
|
|
"Automagic is ON, % prefix IS NOT needed for line magics."
|
|
]
|
|
},
|
|
"execution_count": 2,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"# List all magic commands\n",
|
|
"%lsmagic"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"import numpy as np \n",
|
|
"x = np.random.normal(0, 1, 1_000_000)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"1.03 ms ± 4.93 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"%%timeit \n",
|
|
"x.mean()**2 - (x**2).mean()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Send variables back and fourth in bash\n",
|
|
"\n",
|
|
"The strings will be saved as files in the working directory"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 5,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"string_0\n",
|
|
"string_1\n",
|
|
"string_2\n",
|
|
"string_3\n",
|
|
"string_4\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"for i in range(5):\n",
|
|
" string = \"string_{}\".format(i)\n",
|
|
" print(string)\n",
|
|
" !touch $string"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 6,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"-rw-r--r-- 1 jovyan users 0 Dec 19 08:44 string_0\n",
|
|
"-rw-r--r-- 1 jovyan users 0 Dec 19 08:44 string_1\n",
|
|
"-rw-r--r-- 1 jovyan users 0 Dec 19 08:44 string_2\n",
|
|
"-rw-r--r-- 1 jovyan users 0 Dec 19 08:44 string_3\n",
|
|
"-rw-r--r-- 1 jovyan users 0 Dec 19 08:44 string_4\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"!ls -l | grep string_"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 7,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"['string_0', 'string_1', 'string_2', 'string_3', 'string_4']"
|
|
]
|
|
},
|
|
"execution_count": 7,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"files = !ls -1 string_*\n",
|
|
"!rm string_*\n",
|
|
"files"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"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.7.3"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 4
|
|
}
|