Commit 90748b5f authored by Mario Chirinos Colunga's avatar Mario Chirinos Colunga 💬

numpy

parent be4a6ac1
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 5,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 6,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
" [3.+0.j, 4.+0.j]])" " [3.+0.j, 4.+0.j]])"
] ]
}, },
"execution_count": 5, "execution_count": 6,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 7,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
" [0., 0., 0., 0.]])" " [0., 0., 0., 0.]])"
] ]
}, },
"execution_count": 6, "execution_count": 7,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": 8,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -109,7 +109,7 @@ ...@@ -109,7 +109,7 @@
" [1., 1., 1., 1.]])" " [1., 1., 1., 1.]])"
] ]
}, },
"execution_count": 7, "execution_count": 8,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 8, "execution_count": 9,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -131,7 +131,7 @@ ...@@ -131,7 +131,7 @@
" [1., 1., 1., 1.]])" " [1., 1., 1., 1.]])"
] ]
}, },
"execution_count": 8, "execution_count": 9,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -140,6 +140,30 @@ ...@@ -140,6 +140,30 @@
"np.empty( (3,4) ) " "np.empty( (3,4) ) "
] ]
}, },
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[1., 0., 0., 0., 0.],\n",
" [0., 1., 0., 0., 0.],\n",
" [0., 0., 1., 0., 0.],\n",
" [0., 0., 0., 1., 0.],\n",
" [0., 0., 0., 0., 1.]])"
]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.eye(5)"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
...@@ -149,7 +173,7 @@ ...@@ -149,7 +173,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": 10,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -159,7 +183,7 @@ ...@@ -159,7 +183,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 10, "execution_count": 11,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -168,7 +192,7 @@ ...@@ -168,7 +192,7 @@
"array([20, 29, 38, 47])" "array([20, 29, 38, 47])"
] ]
}, },
"execution_count": 10, "execution_count": 11,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -180,7 +204,7 @@ ...@@ -180,7 +204,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 11, "execution_count": 12,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -189,7 +213,7 @@ ...@@ -189,7 +213,7 @@
"array([ 40, 60, 80, 100])" "array([ 40, 60, 80, 100])"
] ]
}, },
"execution_count": 11, "execution_count": 12,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -201,7 +225,7 @@ ...@@ -201,7 +225,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": 13,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -210,7 +234,7 @@ ...@@ -210,7 +234,7 @@
"array([0, 1, 4, 9])" "array([0, 1, 4, 9])"
] ]
}, },
"execution_count": 12, "execution_count": 13,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -222,7 +246,7 @@ ...@@ -222,7 +246,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 13, "execution_count": 14,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -231,7 +255,7 @@ ...@@ -231,7 +255,7 @@
"array([ True, True, True, False])" "array([ True, True, True, False])"
] ]
}, },
"execution_count": 13, "execution_count": 14,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -243,7 +267,7 @@ ...@@ -243,7 +267,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 14, "execution_count": 15,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -252,7 +276,7 @@ ...@@ -252,7 +276,7 @@
"array([ 0, 30, 80, 150])" "array([ 0, 30, 80, 150])"
] ]
}, },
"execution_count": 14, "execution_count": 15,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -271,7 +295,7 @@ ...@@ -271,7 +295,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 15, "execution_count": 16,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -280,7 +304,7 @@ ...@@ -280,7 +304,7 @@
"True" "True"
] ]
}, },
"execution_count": 15, "execution_count": 16,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -291,7 +315,7 @@ ...@@ -291,7 +315,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 43, "execution_count": 17,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
...@@ -301,7 +325,7 @@ ...@@ -301,7 +325,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 45, "execution_count": 18,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -311,7 +335,7 @@ ...@@ -311,7 +335,7 @@
" [ True, True]])" " [ True, True]])"
] ]
}, },
"execution_count": 45, "execution_count": 18,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -322,7 +346,7 @@ ...@@ -322,7 +346,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 50, "execution_count": 19,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -331,7 +355,7 @@ ...@@ -331,7 +355,7 @@
"66" "66"
] ]
}, },
"execution_count": 50, "execution_count": 19,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -343,7 +367,7 @@ ...@@ -343,7 +367,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 52, "execution_count": 20,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -352,7 +376,7 @@ ...@@ -352,7 +376,7 @@
"array([12, 15, 18, 21])" "array([12, 15, 18, 21])"
] ]
}, },
"execution_count": 52, "execution_count": 20,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -363,7 +387,7 @@ ...@@ -363,7 +387,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 53, "execution_count": 21,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -372,7 +396,7 @@ ...@@ -372,7 +396,7 @@
"array([ 6, 22, 38])" "array([ 6, 22, 38])"
] ]
}, },
"execution_count": 53, "execution_count": 21,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -390,7 +414,7 @@ ...@@ -390,7 +414,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 56, "execution_count": 22,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -403,7 +427,7 @@ ...@@ -403,7 +427,7 @@
" [40, 41, 42, 43]])" " [40, 41, 42, 43]])"
] ]
}, },
"execution_count": 56, "execution_count": 22,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -417,7 +441,7 @@ ...@@ -417,7 +441,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 59, "execution_count": 23,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -426,7 +450,7 @@ ...@@ -426,7 +450,7 @@
"3" "3"
] ]
}, },
"execution_count": 59, "execution_count": 23,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -437,7 +461,7 @@ ...@@ -437,7 +461,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 62, "execution_count": 24,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -446,7 +470,7 @@ ...@@ -446,7 +470,7 @@
"array([10, 11, 12, 13])" "array([10, 11, 12, 13])"
] ]
}, },
"execution_count": 62, "execution_count": 24,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -457,7 +481,7 @@ ...@@ -457,7 +481,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 63, "execution_count": 25,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -466,7 +490,7 @@ ...@@ -466,7 +490,7 @@
"array([ 1, 11, 21, 31, 41])" "array([ 1, 11, 21, 31, 41])"
] ]
}, },
"execution_count": 63, "execution_count": 25,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -477,7 +501,7 @@ ...@@ -477,7 +501,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 65, "execution_count": 26,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -487,7 +511,7 @@ ...@@ -487,7 +511,7 @@
" [11, 12]])" " [11, 12]])"
] ]
}, },
"execution_count": 65, "execution_count": 26,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -505,7 +529,7 @@ ...@@ -505,7 +529,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 67, "execution_count": 27,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -527,7 +551,7 @@ ...@@ -527,7 +551,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 68, "execution_count": 28,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -571,18 +595,18 @@ ...@@ -571,18 +595,18 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 19, "execution_count": 29,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"array([[9., 7., 7., 6.],\n", "array([[8., 0., 8., 9.],\n",
" [1., 2., 2., 8.],\n", " [6., 1., 5., 9.],\n",
" [9., 2., 4., 1.]])" " [9., 3., 3., 2.]])"
] ]
}, },
"execution_count": 19, "execution_count": 29,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -594,7 +618,7 @@ ...@@ -594,7 +618,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 20, "execution_count": 30,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -603,7 +627,7 @@ ...@@ -603,7 +627,7 @@
"(3, 4)" "(3, 4)"
] ]
}, },
"execution_count": 20, "execution_count": 30,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -614,21 +638,21 @@ ...@@ -614,21 +638,21 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 22, "execution_count": 31,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"array([[9., 7.],\n", "array([[8., 0.],\n",
" [7., 6.],\n", " [8., 9.],\n",
" [1., 2.],\n", " [6., 1.],\n",
" [2., 8.],\n", " [5., 9.],\n",
" [9., 2.],\n", " [9., 3.],\n",
" [4., 1.]])" " [3., 2.]])"
] ]
}, },
"execution_count": 22, "execution_count": 31,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -639,19 +663,19 @@ ...@@ -639,19 +663,19 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 23, "execution_count": 32,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"array([[9., 1., 9.],\n", "array([[8., 6., 9.],\n",
" [7., 2., 2.],\n", " [0., 1., 3.],\n",
" [7., 2., 4.],\n", " [8., 5., 3.],\n",
" [6., 8., 1.]])" " [9., 9., 2.]])"
] ]
}, },
"execution_count": 23, "execution_count": 32,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -662,7 +686,7 @@ ...@@ -662,7 +686,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 27, "execution_count": 33,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -674,7 +698,7 @@ ...@@ -674,7 +698,7 @@
" [ True, True, True]])" " [ True, True, True]])"
] ]
}, },
"execution_count": 27, "execution_count": 33,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -685,7 +709,7 @@ ...@@ -685,7 +709,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 29, "execution_count": 34,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -694,7 +718,7 @@ ...@@ -694,7 +718,7 @@
"(4, 3)" "(4, 3)"
] ]
}, },
"execution_count": 29, "execution_count": 34,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -705,10 +729,24 @@ ...@@ -705,10 +729,24 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 35,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"data": {
"text/plain": [
"array([[8., 0., 8., 9.],\n",
" [6., 1., 5., 9.],\n",
" [9., 3., 3., 2.]])"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"# La dimencion con -1 se calcula automaticamente\n",
"a.reshape(3,-1)" "a.reshape(3,-1)"
] ]
}, },
...@@ -716,7 +754,43 @@ ...@@ -716,7 +754,43 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"## 2.2 Pandas" "## 5.2 Ejercicos\n",
"\n",
"### 5.2.1 Sin utilizar numpy escribe una funcion para obten el producto punto de dos vectores."
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [],
"source": [
"a = [2, 5.6, 9, 8, 10]\n",
"b = [1, 3, 2.4, 2, 11]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 5.2.2 Sin utilizar numpy escribe una funcion que obtenga la multiplicacion de dos matrices.\n"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [],
"source": [
"A = [[1,2,3],[4,5,6]]\n",
"B = [[7,8],[9,10],[11,12]]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 5.2.3 Utiliza numpy para probar que las dos funciones anteriores dan el resultado correcto."
] ]
}, },
{ {
...@@ -726,6 +800,43 @@ ...@@ -726,6 +800,43 @@
"outputs": [], "outputs": [],
"source": [] "source": []
}, },
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 5.2.4 Utilizando solo lo visto hasta el momento de numpy escribe una funcion que encuentre la inversa de una matriz por el metodo de Gauss-Jordan.\n",
"[Wikipedia](https://en.wikipedia.org/wiki/Gaussian_elimination): En matemáticas, la eliminación de Gauss Jordan, llamada así en honor de Carl Friedrich Gauss y Wilhelm Jordan es un algoritmo del álgebra lineal que se usa para determinar las soluciones de un sistema de ecuaciones lineales, para encontrar matrices e inversas. Un sistema de ecuaciones se resuelve por el método de Gauss cuando se obtienen sus soluciones mediante la reducción del sistema dado a otro equivalente en el que cada ecuación tiene una incógnita menos que la anterior. El método de Gauss transforma la matriz de coeficientes en una matriz triangular superior. El método de Gauss-Jordan continúa el proceso de transformación hasta obtener una matriz diagonal"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2.2 Pandas"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[1., 0., 0.],\n",
" [0., 1., 0.],\n",
" [0., 0., 1.]])"
]
},
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.eye(3)"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment