Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submission 1-2 Assgnmnt #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 138 additions & 27 deletions Assignment_1_1/Assignment_1_1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import pickle\n",
Expand All @@ -12,13 +14,26 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"1000"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"## Code to load the array\n",
"with open('array.pickle', 'rb') as p:\n",
" arr = pickle.load(p)"
" arr = pickle.load(p)\n",
" \n",
"len(arr) "
]
},
{
Expand All @@ -37,12 +52,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"(20, 50)"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"## BEGIN CODE\n",
"\n",
"arr_resized = np.resize(arr,(20,50))\n",
"arr_resized.shape\n",
"## END CODE"
]
},
Expand All @@ -55,12 +82,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"(50, 20)"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"## BEGIN CODE\n",
"\n",
"arr_resized_trns = arr_resized.T\n",
"arr_resized_trns.shape\n",
"## END CODE"
]
},
Expand All @@ -73,12 +112,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"(20, 20)"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"## BEGIN CODE\n",
"\n",
"DP = np.dot(arr_resized,arr_resized_trns)\n",
"DP.shape\n",
"## END CODE"
]
},
Expand All @@ -91,12 +142,30 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"array([2365442.27809957, 3002112.3995789 , 2779184.43777157,\n",
" 2477210.32440039, 2627759.87742664, 2220803.79590608,\n",
" 2429710.18283941, 2508044.22721641, 2459318.36600334,\n",
" 2325031.07739166, 2896081.10050922, 2762062.07921721,\n",
" 2660473.74582437, 2141287.18395127, 2694809.41626161,\n",
" 2254508.32241154, 2480788.07237605, 2727792.51946167,\n",
" 2586794.20382212, 2681242.33967484])"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"## BEGIN CODE\n",
"\n",
"DP_RSum = DP.sum(axis=1)\n",
"DP_RSum\n",
"## END CODE"
]
},
Expand All @@ -109,12 +178,28 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 26,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"array([1537.99944021, 1732.66049749, 1667.08861125, 1573.91560269,\n",
" 1621.03666751, 1490.23615441, 1558.75276514, 1583.68059507,\n",
" 1568.2214021 , 1524.80525884, 1701.7876191 , 1661.94526962,\n",
" 1631.09587266, 1463.31376811, 1641.58746836, 1501.50202211,\n",
" 1575.05176816, 1651.60301509, 1608.35139314, 1637.44995028])"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"## BEGIN CODE\n",
"\n",
"DP_RSum_sqrt = np.sqrt(DP_RSum)\n",
"DP_RSum_sqrt\n",
"## END CODE"
]
},
Expand All @@ -127,12 +212,27 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 27,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"array([-0.98203514, -0.99739839, 0.88988262, 0.0223149 , -0.02513909,\n",
" 0.90063852, 0.49931585, 0.31257026, -0.53682381, -0.90561256,\n",
" -0.81665967, -0.04274285, -0.57228164, -0.61973772, 0.99446036,\n",
" -0.17830768, -0.89740342, -0.76736444, -0.14354788, -0.62893124])"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"## BEGIN CODE\n",
"\n",
"Sine_values = np.sin(DP_RSum_sqrt)\n",
"Sine_values\n",
"## END CODE"
]
},
Expand All @@ -145,16 +245,27 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"execution_count": 28,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"## Assign the name of the variable containing the final matrix to VARIABLE_NAME variable.\n",
"\n",
"VARIABLE_NAME = \n",
"VARIABLE_NAME = Sine_values\n",
"with open('submission.pickle', 'wb') as p:\n",
" pickle.dump(VARIABLE_NAME, p)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -173,7 +284,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.4"
"version": "3.6.3"
}
},
"nbformat": 4,
Expand Down
Binary file added Assignment_1_1/submission.pickle
Binary file not shown.
Loading