Skip to content

Instantly share code, notes, and snippets.

@bshishov
Last active February 13, 2017 22:53
Show Gist options
  • Save bshishov/b88ee7639972d3b35647485b733dde15 to your computer and use it in GitHub Desktop.
Save bshishov/b88ee7639972d3b35647485b733dde15 to your computer and use it in GitHub Desktop.
Numpy test of array (R,) and (R,1)
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 38,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'numpy.ndarray'> (10,)\n"
]
},
{
"data": {
"text/plain": [
"array([ 0.71170517, 0.38573419, 0.36537496, 0.69382252, 0.00328246,\n",
" 0.96243389, 0.66241115, 0.30933029, 0.53710231, 0.76611932])"
]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x = np.random.random(10)\n",
"print(type(x), x.shape)\n",
"x"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"array([ 0.71170517, 0.38573419, 0.36537496, 0.69382252, 0.00328246,\n",
" 0.96243389, 0.66241115, 0.30933029, 0.53710231, 0.76611932])"
]
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x.T"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"3.6063848929402131"
]
},
"execution_count": 41,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x.dot(x)"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"3.6063848929402131"
]
},
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x.dot(x.T)"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'numpy.ndarray'> (10, 1)\n"
]
},
{
"data": {
"text/plain": [
"array([[ 0.71170517],\n",
" [ 0.38573419],\n",
" [ 0.36537496],\n",
" [ 0.69382252],\n",
" [ 0.00328246],\n",
" [ 0.96243389],\n",
" [ 0.66241115],\n",
" [ 0.30933029],\n",
" [ 0.53710231],\n",
" [ 0.76611932]])"
]
},
"execution_count": 43,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"y = np.array([x]).T\n",
"print(type(y), y.shape)\n",
"y"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {
"collapsed": false
},
"outputs": [
{
"ename": "ValueError",
"evalue": "shapes (10,1) and (10,1) not aligned: 1 (dim 1) != 10 (dim 0)",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-44-a13e054596f4>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0my\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdot\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0my\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;31mValueError\u001b[0m: shapes (10,1) and (10,1) not aligned: 1 (dim 1) != 10 (dim 0)"
]
}
],
"source": [
"y.dot(y)"
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"array([[ 5.06524254e-01, 2.74529020e-01, 2.60039247e-01,\n",
" 4.93797073e-01, 2.33614223e-03, 6.84969179e-01,\n",
" 4.71441443e-01, 2.20151968e-01, 3.82258491e-01,\n",
" 5.45251084e-01],\n",
" [ 2.74529020e-01, 1.48790867e-01, 1.40937614e-01,\n",
" 2.67631067e-01, 1.26615623e-03, 3.71243659e-01,\n",
" 2.55514630e-01, 1.19319270e-01, 2.07178725e-01,\n",
" 2.95518417e-01],\n",
" [ 2.60039247e-01, 1.40937614e-01, 1.33498859e-01,\n",
" 2.53505371e-01, 1.19932789e-03, 3.51649241e-01,\n",
" 2.42028445e-01, 1.13021541e-01, 1.96243732e-01,\n",
" 2.79920813e-01],\n",
" [ 4.93797073e-01, 2.67631067e-01, 2.53505371e-01,\n",
" 4.81389682e-01, 2.27744316e-03, 6.67758302e-01,\n",
" 4.59595771e-01, 2.14620320e-01, 3.72653674e-01,\n",
" 5.31550834e-01],\n",
" [ 2.33614223e-03, 1.26615623e-03, 1.19932789e-03,\n",
" 2.27744316e-03, 1.07745295e-05, 3.15914868e-03,\n",
" 2.17433668e-03, 1.01536364e-03, 1.76301569e-03,\n",
" 2.51475438e-03],\n",
" [ 6.84969179e-01, 3.71243659e-01, 3.51649241e-01,\n",
" 6.67758302e-01, 3.15914868e-03, 9.26278993e-01,\n",
" 6.37526941e-01, 2.97709955e-01, 5.16925464e-01,\n",
" 7.37339198e-01],\n",
" [ 4.71441443e-01, 2.55514630e-01, 2.42028445e-01,\n",
" 4.59595771e-01, 2.17433668e-03, 6.37526941e-01,\n",
" 4.38788532e-01, 2.04903834e-01, 3.55782558e-01,\n",
" 5.07485981e-01],\n",
" [ 2.20151968e-01, 1.19319270e-01, 1.13021541e-01,\n",
" 2.14620320e-01, 1.01536364e-03, 2.97709955e-01,\n",
" 2.04903834e-01, 9.56852287e-02, 1.66142013e-01,\n",
" 2.36983912e-01],\n",
" [ 3.82258491e-01, 2.07178725e-01, 1.96243732e-01,\n",
" 3.72653674e-01, 1.76301569e-03, 5.16925464e-01,\n",
" 3.55782558e-01, 1.66142013e-01, 2.88478889e-01,\n",
" 4.11484455e-01],\n",
" [ 5.45251084e-01, 2.95518417e-01, 2.79920813e-01,\n",
" 5.31550834e-01, 2.51475438e-03, 7.37339198e-01,\n",
" 5.07485981e-01, 2.36983912e-01, 4.11484455e-01,\n",
" 5.86938813e-01]])"
]
},
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"y.dot(y.T)"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {
"collapsed": false
},
"outputs": [
{
"ename": "ValueError",
"evalue": "shapes (10,1) and (10,) not aligned: 1 (dim 1) != 10 (dim 0)",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-46-5a672ad87881>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0my\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdot\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;31mValueError\u001b[0m: shapes (10,1) and (10,) not aligned: 1 (dim 1) != 10 (dim 0)"
]
}
],
"source": [
"y.dot(x)"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {
"collapsed": false
},
"outputs": [
{
"ename": "ValueError",
"evalue": "shapes (10,1) and (10,) not aligned: 1 (dim 1) != 10 (dim 0)",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-47-c64a32e34212>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0my\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdot\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mx\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mT\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;31mValueError\u001b[0m: shapes (10,1) and (10,) not aligned: 1 (dim 1) != 10 (dim 0)"
]
}
],
"source": [
"y.dot(x.T)"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"array([ 3.60638489])"
]
},
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"y.T.dot(x)"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"array([[ 3.60638489]])"
]
},
"execution_count": 49,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"y.T.dot(y)"
]
},
{
"cell_type": "code",
"execution_count": 50,
"metadata": {
"collapsed": false
},
"outputs": [
{
"ename": "ValueError",
"evalue": "shapes (1,10) and (1,10) not aligned: 10 (dim 1) != 1 (dim 0)",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-50-ebbbad4c3483>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0my\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mT\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdot\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0my\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mT\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;31mValueError\u001b[0m: shapes (1,10) and (1,10) not aligned: 10 (dim 1) != 1 (dim 0)"
]
}
],
"source": [
"y.T.dot(y.T)"
]
},
{
"cell_type": "code",
"execution_count": 51,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"array([ 5.06524254e-01, 1.48790867e-01, 1.33498859e-01,\n",
" 4.81389682e-01, 1.07745295e-05, 9.26278993e-01,\n",
" 4.38788532e-01, 9.56852287e-02, 2.88478889e-01,\n",
" 5.86938813e-01])"
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x ** 2"
]
},
{
"cell_type": "code",
"execution_count": 52,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"array([[ 5.06524254e-01],\n",
" [ 1.48790867e-01],\n",
" [ 1.33498859e-01],\n",
" [ 4.81389682e-01],\n",
" [ 1.07745295e-05],\n",
" [ 9.26278993e-01],\n",
" [ 4.38788532e-01],\n",
" [ 9.56852287e-02],\n",
" [ 2.88478889e-01],\n",
" [ 5.86938813e-01]])"
]
},
"execution_count": 52,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"y ** 2"
]
},
{
"cell_type": "code",
"execution_count": 53,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"array([[ 5.06524254e-01, 2.74529020e-01, 2.60039247e-01,\n",
" 4.93797073e-01, 2.33614223e-03, 6.84969179e-01,\n",
" 4.71441443e-01, 2.20151968e-01, 3.82258491e-01,\n",
" 5.45251084e-01],\n",
" [ 2.74529020e-01, 1.48790867e-01, 1.40937614e-01,\n",
" 2.67631067e-01, 1.26615623e-03, 3.71243659e-01,\n",
" 2.55514630e-01, 1.19319270e-01, 2.07178725e-01,\n",
" 2.95518417e-01],\n",
" [ 2.60039247e-01, 1.40937614e-01, 1.33498859e-01,\n",
" 2.53505371e-01, 1.19932789e-03, 3.51649241e-01,\n",
" 2.42028445e-01, 1.13021541e-01, 1.96243732e-01,\n",
" 2.79920813e-01],\n",
" [ 4.93797073e-01, 2.67631067e-01, 2.53505371e-01,\n",
" 4.81389682e-01, 2.27744316e-03, 6.67758302e-01,\n",
" 4.59595771e-01, 2.14620320e-01, 3.72653674e-01,\n",
" 5.31550834e-01],\n",
" [ 2.33614223e-03, 1.26615623e-03, 1.19932789e-03,\n",
" 2.27744316e-03, 1.07745295e-05, 3.15914868e-03,\n",
" 2.17433668e-03, 1.01536364e-03, 1.76301569e-03,\n",
" 2.51475438e-03],\n",
" [ 6.84969179e-01, 3.71243659e-01, 3.51649241e-01,\n",
" 6.67758302e-01, 3.15914868e-03, 9.26278993e-01,\n",
" 6.37526941e-01, 2.97709955e-01, 5.16925464e-01,\n",
" 7.37339198e-01],\n",
" [ 4.71441443e-01, 2.55514630e-01, 2.42028445e-01,\n",
" 4.59595771e-01, 2.17433668e-03, 6.37526941e-01,\n",
" 4.38788532e-01, 2.04903834e-01, 3.55782558e-01,\n",
" 5.07485981e-01],\n",
" [ 2.20151968e-01, 1.19319270e-01, 1.13021541e-01,\n",
" 2.14620320e-01, 1.01536364e-03, 2.97709955e-01,\n",
" 2.04903834e-01, 9.56852287e-02, 1.66142013e-01,\n",
" 2.36983912e-01],\n",
" [ 3.82258491e-01, 2.07178725e-01, 1.96243732e-01,\n",
" 3.72653674e-01, 1.76301569e-03, 5.16925464e-01,\n",
" 3.55782558e-01, 1.66142013e-01, 2.88478889e-01,\n",
" 4.11484455e-01],\n",
" [ 5.45251084e-01, 2.95518417e-01, 2.79920813e-01,\n",
" 5.31550834e-01, 2.51475438e-03, 7.37339198e-01,\n",
" 5.07485981e-01, 2.36983912e-01, 4.11484455e-01,\n",
" 5.86938813e-01]])"
]
},
"execution_count": 53,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"y * x"
]
},
{
"cell_type": "code",
"execution_count": 54,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"array([[ 5.06524254e-01],\n",
" [ 1.48790867e-01],\n",
" [ 1.33498859e-01],\n",
" [ 4.81389682e-01],\n",
" [ 1.07745295e-05],\n",
" [ 9.26278993e-01],\n",
" [ 4.38788532e-01],\n",
" [ 9.56852287e-02],\n",
" [ 2.88478889e-01],\n",
" [ 5.86938813e-01]])"
]
},
"execution_count": 54,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"y * y"
]
},
{
"cell_type": "code",
"execution_count": 55,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"array([ 5.06524254e-01, 1.48790867e-01, 1.33498859e-01,\n",
" 4.81389682e-01, 1.07745295e-05, 9.26278993e-01,\n",
" 4.38788532e-01, 9.56852287e-02, 2.88478889e-01,\n",
" 5.86938813e-01])"
]
},
"execution_count": 55,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x * x"
]
},
{
"cell_type": "code",
"execution_count": 56,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"array([ 1.4050762 , 2.5924588 , 2.73691445, 1.44129079,\n",
" 304.64976128, 1.03903241, 1.50963642, 3.23279042,\n",
" 1.86184268, 1.3052797 ])"
]
},
"execution_count": 56,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x ** -1"
]
},
{
"cell_type": "code",
"execution_count": 57,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"array([[ 1.4050762 ],\n",
" [ 2.5924588 ],\n",
" [ 2.73691445],\n",
" [ 1.44129079],\n",
" [ 304.64976128],\n",
" [ 1.03903241],\n",
" [ 1.50963642],\n",
" [ 3.23279042],\n",
" [ 1.86184268],\n",
" [ 1.3052797 ]])"
]
},
"execution_count": 57,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"y ** -1"
]
},
{
"cell_type": "code",
"execution_count": 58,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"array([ 0.71170517, 0.38573419, 0.36537496, 0.69382252, 0.00328246,\n",
" 0.96243389, 0.66241115, 0.30933029, 0.53710231, 0.76611932])"
]
},
"execution_count": 58,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"y.dot([1])"
]
},
{
"cell_type": "code",
"execution_count": 59,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"array([ 0.71170517, 0.38573419, 0.36537496, 0.69382252, 0.00328246,\n",
" 0.96243389, 0.66241115, 0.30933029, 0.53710231, 0.76611932])"
]
},
"execution_count": 59,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x.dot(1)"
]
},
{
"cell_type": "code",
"execution_count": 60,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"matrix([[ 0.71170517],\n",
" [ 0.38573419],\n",
" [ 0.36537496],\n",
" [ 0.69382252],\n",
" [ 0.00328246],\n",
" [ 0.96243389],\n",
" [ 0.66241115],\n",
" [ 0.30933029],\n",
" [ 0.53710231],\n",
" [ 0.76611932]])"
]
},
"execution_count": 60,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"xm = np.mat(x).T\n",
"xm"
]
},
{
"cell_type": "code",
"execution_count": 61,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"matrix([[ 0.71170517],\n",
" [ 0.38573419],\n",
" [ 0.36537496],\n",
" [ 0.69382252],\n",
" [ 0.00328246],\n",
" [ 0.96243389],\n",
" [ 0.66241115],\n",
" [ 0.30933029],\n",
" [ 0.53710231],\n",
" [ 0.76611932]])"
]
},
"execution_count": 61,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ym = np.mat(y)\n",
"ym"
]
},
{
"cell_type": "code",
"execution_count": 62,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"matrix([[ 5.06524254e-01, 2.74529020e-01, 2.60039247e-01,\n",
" 4.93797073e-01, 2.33614223e-03, 6.84969179e-01,\n",
" 4.71441443e-01, 2.20151968e-01, 3.82258491e-01,\n",
" 5.45251084e-01],\n",
" [ 2.74529020e-01, 1.48790867e-01, 1.40937614e-01,\n",
" 2.67631067e-01, 1.26615623e-03, 3.71243659e-01,\n",
" 2.55514630e-01, 1.19319270e-01, 2.07178725e-01,\n",
" 2.95518417e-01],\n",
" [ 2.60039247e-01, 1.40937614e-01, 1.33498859e-01,\n",
" 2.53505371e-01, 1.19932789e-03, 3.51649241e-01,\n",
" 2.42028445e-01, 1.13021541e-01, 1.96243732e-01,\n",
" 2.79920813e-01],\n",
" [ 4.93797073e-01, 2.67631067e-01, 2.53505371e-01,\n",
" 4.81389682e-01, 2.27744316e-03, 6.67758302e-01,\n",
" 4.59595771e-01, 2.14620320e-01, 3.72653674e-01,\n",
" 5.31550834e-01],\n",
" [ 2.33614223e-03, 1.26615623e-03, 1.19932789e-03,\n",
" 2.27744316e-03, 1.07745295e-05, 3.15914868e-03,\n",
" 2.17433668e-03, 1.01536364e-03, 1.76301569e-03,\n",
" 2.51475438e-03],\n",
" [ 6.84969179e-01, 3.71243659e-01, 3.51649241e-01,\n",
" 6.67758302e-01, 3.15914868e-03, 9.26278993e-01,\n",
" 6.37526941e-01, 2.97709955e-01, 5.16925464e-01,\n",
" 7.37339198e-01],\n",
" [ 4.71441443e-01, 2.55514630e-01, 2.42028445e-01,\n",
" 4.59595771e-01, 2.17433668e-03, 6.37526941e-01,\n",
" 4.38788532e-01, 2.04903834e-01, 3.55782558e-01,\n",
" 5.07485981e-01],\n",
" [ 2.20151968e-01, 1.19319270e-01, 1.13021541e-01,\n",
" 2.14620320e-01, 1.01536364e-03, 2.97709955e-01,\n",
" 2.04903834e-01, 9.56852287e-02, 1.66142013e-01,\n",
" 2.36983912e-01],\n",
" [ 3.82258491e-01, 2.07178725e-01, 1.96243732e-01,\n",
" 3.72653674e-01, 1.76301569e-03, 5.16925464e-01,\n",
" 3.55782558e-01, 1.66142013e-01, 2.88478889e-01,\n",
" 4.11484455e-01],\n",
" [ 5.45251084e-01, 2.95518417e-01, 2.79920813e-01,\n",
" 5.31550834e-01, 2.51475438e-03, 7.37339198e-01,\n",
" 5.07485981e-01, 2.36983912e-01, 4.11484455e-01,\n",
" 5.86938813e-01]])"
]
},
"execution_count": 62,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"xm * ym.T"
]
},
{
"cell_type": "code",
"execution_count": 63,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"matrix([[ 5.06524254e-01, 2.74529020e-01, 2.60039247e-01,\n",
" 4.93797073e-01, 2.33614223e-03, 6.84969179e-01,\n",
" 4.71441443e-01, 2.20151968e-01, 3.82258491e-01,\n",
" 5.45251084e-01],\n",
" [ 2.74529020e-01, 1.48790867e-01, 1.40937614e-01,\n",
" 2.67631067e-01, 1.26615623e-03, 3.71243659e-01,\n",
" 2.55514630e-01, 1.19319270e-01, 2.07178725e-01,\n",
" 2.95518417e-01],\n",
" [ 2.60039247e-01, 1.40937614e-01, 1.33498859e-01,\n",
" 2.53505371e-01, 1.19932789e-03, 3.51649241e-01,\n",
" 2.42028445e-01, 1.13021541e-01, 1.96243732e-01,\n",
" 2.79920813e-01],\n",
" [ 4.93797073e-01, 2.67631067e-01, 2.53505371e-01,\n",
" 4.81389682e-01, 2.27744316e-03, 6.67758302e-01,\n",
" 4.59595771e-01, 2.14620320e-01, 3.72653674e-01,\n",
" 5.31550834e-01],\n",
" [ 2.33614223e-03, 1.26615623e-03, 1.19932789e-03,\n",
" 2.27744316e-03, 1.07745295e-05, 3.15914868e-03,\n",
" 2.17433668e-03, 1.01536364e-03, 1.76301569e-03,\n",
" 2.51475438e-03],\n",
" [ 6.84969179e-01, 3.71243659e-01, 3.51649241e-01,\n",
" 6.67758302e-01, 3.15914868e-03, 9.26278993e-01,\n",
" 6.37526941e-01, 2.97709955e-01, 5.16925464e-01,\n",
" 7.37339198e-01],\n",
" [ 4.71441443e-01, 2.55514630e-01, 2.42028445e-01,\n",
" 4.59595771e-01, 2.17433668e-03, 6.37526941e-01,\n",
" 4.38788532e-01, 2.04903834e-01, 3.55782558e-01,\n",
" 5.07485981e-01],\n",
" [ 2.20151968e-01, 1.19319270e-01, 1.13021541e-01,\n",
" 2.14620320e-01, 1.01536364e-03, 2.97709955e-01,\n",
" 2.04903834e-01, 9.56852287e-02, 1.66142013e-01,\n",
" 2.36983912e-01],\n",
" [ 3.82258491e-01, 2.07178725e-01, 1.96243732e-01,\n",
" 3.72653674e-01, 1.76301569e-03, 5.16925464e-01,\n",
" 3.55782558e-01, 1.66142013e-01, 2.88478889e-01,\n",
" 4.11484455e-01],\n",
" [ 5.45251084e-01, 2.95518417e-01, 2.79920813e-01,\n",
" 5.31550834e-01, 2.51475438e-03, 7.37339198e-01,\n",
" 5.07485981e-01, 2.36983912e-01, 4.11484455e-01,\n",
" 5.86938813e-01]])"
]
},
"execution_count": 63,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"xm.dot(xm.T)"
]
},
{
"cell_type": "code",
"execution_count": 64,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"matrix([[ 3.60638489]])"
]
},
"execution_count": 64,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"xm.T.dot(xm)"
]
},
{
"cell_type": "code",
"execution_count": 65,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"matrix([[ 3.60638489]])"
]
},
"execution_count": 65,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"xm.T * xm"
]
},
{
"cell_type": "code",
"execution_count": 66,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"matrix([[ 3.60638489]])"
]
},
"execution_count": 66,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ym.T * y"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"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.5.1"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment