Skip to content

Instantly share code, notes, and snippets.

@isezen
Created February 28, 2017 00:35
Show Gist options
  • Save isezen/f17d744c3318c92cfee07c4ec33691af to your computer and use it in GitHub Desktop.
Save isezen/f17d744c3318c92cfee07c4ec33691af to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Hello this a header\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {
"collapsed": false,
"scrolled": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Length of x : 100\n",
"Mean of x : 1.66565914895\n",
"Standard Deviation of x : 2.94862195594\n",
"--------\n",
"sum of x : 166.565914895\n",
"sum/len : 1.66565914895\n",
"8.69437143904\n"
]
},
{
"data": {
"text/plain": [
"2.9486219559374667"
]
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import numpy as np\n",
"x = np.random.normal(2, 3, 100) # mean, sd, count\n",
"print 'Length of x : {0}'.format(len(x))\n",
"print 'Mean of x : {0}'.format(np.mean(x))\n",
"print 'Standard Deviation of x : {0}'.format(np.std(x))\n",
"print '--------'\n",
"print 'sum of x : {0}'.format(np.sum(x))\n",
"print 'sum/len : {0}'.format(np.sum(x)/len(x))\n",
"var = np.sum(((x - np.mean(x))**2)/(len(x))) # Variance\n",
"print var\n",
"np.sqrt(var)"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<type 'list'>\n",
"<type 'numpy.ndarray'>\n",
"[0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1024, 1089, 1156, 1225, 1296, 1369, 1444, 1521, 1600, 1681, 1764, 1849, 1936, 2025, 2116, 2209, 2304, 2401, 2500, 2601, 2704, 2809, 2916, 3025, 3136, 3249, 3364, 3481, 3600, 3721, 3844, 3969, 4096, 4225, 4356, 4489, 4624, 4761, 4900, 5041, 5184, 5329, 5476, 5625, 5776, 5929, 6084, 6241, 6400, 6561, 6724, 6889, 7056, 7225, 7396, 7569, 7744, 7921, 8100, 8281, 8464, 8649, 8836, 9025, 9216, 9409, 9604]\n"
]
}
],
"source": [
"N = 100\n",
"x = np.linspace(0, stop=N-1, num=N)\n",
"y = range(0, N - 1)\n",
"z = [(i**2) for i in y]\n",
"print type(y)\n",
"print type(x)\n",
"print z"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"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.13"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment