2015-04-10 01:25:59 +08:00
|
|
|
{
|
2015-04-15 02:19:07 +08:00
|
|
|
"cells": [
|
2015-04-10 01:25:59 +08:00
|
|
|
{
|
2015-04-15 02:19:07 +08:00
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"# NumPy\n",
|
|
|
|
"\n",
|
2015-05-31 21:38:47 +08:00
|
|
|
"Credits: Forked from [Parallel Machine Learning with scikit-learn and IPython](https://github.com/ogrisel/parallel_ml_tutorial) by Olivier Grisel\n",
|
|
|
|
"\n",
|
2015-04-15 02:19:07 +08:00
|
|
|
"* NumPy Arrays, dtype, and shape\n",
|
|
|
|
"* Common Array Operations\n",
|
|
|
|
"* Reshape and Update In-Place\n",
|
|
|
|
"* Combine Arrays\n",
|
|
|
|
"* Create Sample Data"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 1,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"import numpy as np"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"## NumPy Arrays, dtypes, and shapes"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 2,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
|
|
|
"[1 2 3]\n",
|
|
|
|
"(3,)\n",
|
|
|
|
"int64\n"
|
2015-04-10 01:25:59 +08:00
|
|
|
]
|
2015-04-15 02:19:07 +08:00
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"a = np.array([1, 2, 3])\n",
|
|
|
|
"print(a)\n",
|
|
|
|
"print(a.shape)\n",
|
|
|
|
"print(a.dtype)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 3,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
|
|
|
"[[0 2 4]\n",
|
|
|
|
" [1 3 5]]\n",
|
|
|
|
"(2, 3)\n",
|
|
|
|
"int64\n"
|
2015-04-10 01:25:59 +08:00
|
|
|
]
|
2015-04-15 02:19:07 +08:00
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"b = np.array([[0, 2, 4], [1, 3, 5]])\n",
|
|
|
|
"print(b)\n",
|
|
|
|
"print(b.shape)\n",
|
|
|
|
"print(b.dtype)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 4,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"array([ 0., 0., 0., 0., 0.])"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 4,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"np.zeros(5)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 5,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"array([[1, 1, 1, 1],\n",
|
|
|
|
" [1, 1, 1, 1],\n",
|
|
|
|
" [1, 1, 1, 1]], dtype=int32)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 5,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"np.ones(shape=(3, 4), dtype=np.int32)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"## Common Array Operations"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 6,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
|
|
|
"[[ 0. 1. 2. ]\n",
|
|
|
|
" [ 0.5 1.5 2.5]]\n",
|
|
|
|
"(2, 3)\n",
|
|
|
|
"float64\n"
|
2015-04-10 01:27:00 +08:00
|
|
|
]
|
2015-04-15 02:19:07 +08:00
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"c = b * 0.5\n",
|
|
|
|
"print(c)\n",
|
|
|
|
"print(c.shape)\n",
|
|
|
|
"print(c.dtype)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 7,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
|
|
|
"[[ 1. 3. 5. ]\n",
|
|
|
|
" [ 1.5 3.5 5.5]]\n"
|
2015-04-10 01:28:09 +08:00
|
|
|
]
|
2015-04-15 02:19:07 +08:00
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"d = a + c\n",
|
|
|
|
"print(d)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 8,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"array([ 1., 3., 5.])"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 8,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"d[0]"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 9,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"1.0"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 9,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"d[0, 0]"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 10,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"array([ 1. , 1.5])"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 10,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"d[:, 0]"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 11,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"19.5"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 11,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"d.sum()"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 12,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"3.25"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 12,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"d.mean()"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 13,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"array([ 2.5, 6.5, 10.5])"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 13,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"d.sum(axis=0)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 14,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"array([ 3. , 3.5])"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 14,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"d.mean(axis=1)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"## Reshape and Update In-Place"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 15,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
|
|
|
"[ 0 1 2 3 4 5 6 7 8 9 10 11]\n"
|
2015-04-10 01:29:27 +08:00
|
|
|
]
|
2015-04-15 02:19:07 +08:00
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"e = np.arange(12)\n",
|
|
|
|
"print(e)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 16,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
|
|
|
"[[ 0 1 2 3]\n",
|
|
|
|
" [ 4 5 6 7]\n",
|
|
|
|
" [ 8 9 10 11]]\n"
|
2015-04-10 01:30:56 +08:00
|
|
|
]
|
2015-04-10 01:25:59 +08:00
|
|
|
}
|
|
|
|
],
|
2015-04-15 02:19:07 +08:00
|
|
|
"source": [
|
|
|
|
"# f is a view of contents of e\n",
|
|
|
|
"f = e.reshape(3, 4)\n",
|
|
|
|
"print(f)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 17,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"name": "stdout",
|
|
|
|
"output_type": "stream",
|
|
|
|
"text": [
|
|
|
|
"[0 1 2 3 4 0 0 0 0 0 0 0]\n"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"# Set last five values of e to zero\n",
|
|
|
|
"e[5:] = 0\n",
|
|
|
|
"print(e)"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 18,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"array([[0, 1, 2, 3],\n",
|
|
|
|
" [4, 0, 0, 0],\n",
|
|
|
|
" [0, 0, 0, 0]])"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 18,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"# f is also updated\n",
|
|
|
|
"f"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 19,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
" C_CONTIGUOUS : True\n",
|
|
|
|
" F_CONTIGUOUS : False\n",
|
|
|
|
" OWNDATA : False\n",
|
|
|
|
" WRITEABLE : True\n",
|
|
|
|
" ALIGNED : True\n",
|
|
|
|
" UPDATEIFCOPY : False"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 19,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"# OWNDATA shows f does not own its data\n",
|
|
|
|
"f.flags"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"## Combine Arrays"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 20,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"array([1, 2, 3])"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 20,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"a"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 21,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"array([[0, 2, 4],\n",
|
|
|
|
" [1, 3, 5]])"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 21,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"b"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 22,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"array([[ 1. , 3. , 5. ],\n",
|
|
|
|
" [ 1.5, 3.5, 5.5]])"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 22,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"d"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 23,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"array([1, 2, 3, 1, 2, 3, 1, 2, 3])"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 23,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"np.concatenate([a, a, a])"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 24,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"array([[ 1. , 2. , 3. ],\n",
|
|
|
|
" [ 0. , 2. , 4. ],\n",
|
|
|
|
" [ 1. , 3. , 5. ],\n",
|
|
|
|
" [ 1. , 3. , 5. ],\n",
|
|
|
|
" [ 1.5, 3.5, 5.5]])"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 24,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"# Use broadcasting when needed to do this automatically\n",
|
|
|
|
"np.vstack([a, b, d])"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 25,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"text/plain": [
|
|
|
|
"array([[ 0. , 2. , 4. , 1. , 3. , 5. ],\n",
|
|
|
|
" [ 1. , 3. , 5. , 1.5, 3.5, 5.5]])"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"execution_count": 25,
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "execute_result"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"# In machine learning, useful to enrich or \n",
|
|
|
|
"# add new/concatenate features with hstack\n",
|
|
|
|
"np.hstack([b, d])"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "markdown",
|
|
|
|
"metadata": {},
|
|
|
|
"source": [
|
|
|
|
"## Create Sample Data"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 26,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"%matplotlib inline\n",
|
|
|
|
"\n",
|
|
|
|
"import pylab as plt\n",
|
|
|
|
"import seaborn\n",
|
|
|
|
"\n",
|
|
|
|
"seaborn.set()"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 27,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAeMAAAFVCAYAAADc5IdQAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XtwVOed5vGnG4QsUEfIThtsS0aOjF5dBjzxLTGyPcYp\neYORnDhmk0lIdsCIyUzwkpmprVTG2aS2pmarXGVI1Xg9MzWL8MZ2ZWELk2yCZBNjO/bGhM0wWBOS\nIF4wRjIei42MBS0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nCGMAyBLqLDEVwhgAMuxKneVJXe4fos4SExDGAJBB4+ssN6yp1D3UWWIcwhgAMqT1ZJeefem4Ir2D\nqihdrE1rqxReXOD0WMhBhDEApNnl/iHtevWk3jzaqfnzAvri6pv1wJ2lCnI0jCkQxgCQRuPrLBvr\nq1USLnR6LOQ4whgA0mB8nWX9qjI9RJ0lkkQYA0CKqLNEqghjAJgj6iyRLoQxAMzBhDrLB6tUcxN1\nlpgbwhgAZmGkzvKF109pgDpLpAlhDABJGl9n2UidJdKEMAaAGVBniUwjjAFgGtRZIhsIYwCYwpg6\ny5Iibaqvps4SGUEYA4Ckbbtb1dbeLQUkU7pYH19cMLbO8o5SBYMcDSMzCGMAvrdtd6uOtXfHN2LS\n8XfPS++e19KrC/SNh1dQZ4mMo6cNgO+1jQTxOH0DwwQxsoIwBuB7sSlu5yItZAunqQH41kid5WSK\nQ/na+sjKLE8EvyKMAfjS+DrLwaGoLl4elBQP4u1bah2eEH5CGAPwlcnqLL9SV6EPzvfpqb1HFQwG\n9NjDK5weEz5DGAPwjen
|
|
|
|
"text/plain": [
|
|
|
|
"<matplotlib.figure.Figure at 0x10bac8d50>"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "display_data"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"# Create evenly spaced numbers over the specified interval\n",
|
|
|
|
"x = np.linspace(0, 2, 10)\n",
|
|
|
|
"plt.plot(x, 'o-');\n",
|
|
|
|
"plt.show()"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": 28,
|
|
|
|
"metadata": {
|
|
|
|
"collapsed": false
|
|
|
|
},
|
|
|
|
"outputs": [
|
|
|
|
{
|
|
|
|
"data": {
|
|
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAeQAAAFVCAYAAAA+OJwpAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgA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FrFhbHzHizG6/\n+HMqdUkkEsmvCs3ra6Cg4AdKS6/0s9dx4E3EemssFRXP+z1XbW0t11yzhC++iAJuxGZrbzmXGRgH\nTAdGUl8/lfz8omYjC/rwt/C4W3mlJiIW6stJScmViOSvHYoxVg39eCADiEIYY9l+8WSQSV0SieSM\noKnmDvrSpvT0IEpL/4zwhHNRk5qio1cQHl6CPvnJ4XjYJ6HL6XQSE/MmX3wxB7gFWEdJSXKT5Uve\nCW5RUQeIjl6OlvC2FngWSKA5CUzjPEZhs12K2ZyBvvwqIWFok/NfunQj9977IkuXFno+U88nIgW3\nIF5G/CVu9QA+9dkq8gMkbUF6yBKJpFPTUji1NaIdza2pGkub1EeiGbgL2ERiYgWLFk0mN3c76enN\njzU3d7suCxvgbppbC/buh5yQEM+6dTs5enQae/eORHilXYEGLJYXSE6e0My136GkJAx4Gngcp3M0\nYWGP8sgj1xAffwOjRq2mqupRAF599Tm2bbsbs9lMUtJaysq6A7Ow2eDtt1/jttt6sXv3fygpmeY1\nl3wgC5gBQPfumRw79qjyubYdVmG3HyMlxXnGhq3bgzTIEomkRdqiVtXR123KkLaUuKQPQ5eVVVJS\nkk7LNbIj0ZK2umK1fsuiRZMxm82kpIxk48ama3udTifLlu0BxhrOaLGUkpw8vck5quFi43yCEF5p\nI1AEuJg4sW+T9722tpb
|
|
|
|
"text/plain": [
|
|
|
|
"<matplotlib.figure.Figure at 0x10bc3a250>"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"metadata": {},
|
|
|
|
"output_type": "display_data"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"source": [
|
|
|
|
"# Create sample data, add some noise\n",
|
|
|
|
"x = np.random.uniform(1, 100, 1000)\n",
|
|
|
|
"y = np.log(x) + np.random.normal(0, .3, 1000)\n",
|
|
|
|
"\n",
|
|
|
|
"plt.scatter(x, y)\n",
|
|
|
|
"plt.show()"
|
|
|
|
]
|
2015-04-10 01:25:59 +08:00
|
|
|
}
|
2015-04-15 02:19:07 +08:00
|
|
|
],
|
|
|
|
"metadata": {
|
|
|
|
"kernelspec": {
|
|
|
|
"display_name": "Python 2",
|
|
|
|
"language": "python",
|
|
|
|
"name": "python2"
|
|
|
|
},
|
|
|
|
"language_info": {
|
|
|
|
"codemirror_mode": {
|
|
|
|
"name": "ipython",
|
|
|
|
"version": 2
|
|
|
|
},
|
|
|
|
"file_extension": ".py",
|
|
|
|
"mimetype": "text/x-python",
|
|
|
|
"name": "python",
|
|
|
|
"nbconvert_exporter": "python",
|
|
|
|
"pygments_lexer": "ipython2",
|
|
|
|
"version": "2.7.9"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"nbformat": 4,
|
|
|
|
"nbformat_minor": 0
|
|
|
|
}
|