See More

{ "cells": [ { "cell_type": "code", "execution_count": 103, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy\n", "import pandas\n", "import matplotlib.pyplot as plt\n", "from scipy.stats import norm \n", "import numpy as np\n", "\n", "mu_systolic_high, sigma_systolic_high = 140, 5\n", "mu_diastolic_high, sigma_diastolic_high = 90, 5\n", "mu_systolic_low, sigma_systolic_low = 70, 5\n", "mu_diastolic_low, sigma_diastolic_low = 60, 5" ] }, { "cell_type": "code", "execution_count": 104, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "(100,)" ] }, "execution_count": 104, "metadata": {}, "output_type": "execute_result" } ], "source": [ "systolic_high = numpy.random.normal(mu_systolic_high, sigma_systolic_high, 100)\n", "diastolic_high = numpy.random.normal(mu_diastolic_high, sigma_diastolic_high, 100)\n", "systolic_low = numpy.random.normal(mu_systolic_low, sigma_systolic_low, 100)\n", "diastolic_low = numpy.random.normal(mu_diastolic_low, sigma_diastolic_low, 100)\n", "systolic_high.shape" ] }, { "cell_type": "code", "execution_count": 105, "metadata": { "collapsed": false, "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " systolic-high diastolic-high systolic-low diastolic-low\n", "0 136.760512 90.492194 75.610785 58.919102\n", "1 141.940902 81.285726 60.639671 59.284786\n", "2 143.127674 94.196791 75.154056 50.423231\n", "3 136.095111 97.937605 64.290269 56.188862\n", "4 139.366509 88.227898 67.092255 66.533132\n", "5 138.431291 88.157334 81.337549 58.624559\n", "6 126.789473 90.861056 67.841854 66.965385\n", "7 141.121044 86.859313 61.866278 58.011283\n", "8 129.410259 90.089323 75.232383 73.269521\n", "9 143.232058 89.631741 72.333697 63.577845\n", "10 146.253161 86.423532 74.293820 54.155667\n", "11 135.260392 86.591691 63.633401 52.308737\n", "12 143.735404 87.865478 70.935144 63.155199\n", "13 141.894322 94.170978 71.840943 69.145870\n", "14 149.694474 86.532619 65.528090 59.315919\n", "15 139.169448 92.190454 80.373398 59.565634\n", "16 141.661803 85.194274 61.612864 63.143912\n", "17 143.555417 94.772942 73.156100 59.764049\n", "18 138.263481 90.738375 72.361214 60.373349\n", "19 141.846299 87.080390 65.279445 67.033074\n", "20 140.309456 84.141231 77.988164 61.760307\n", "21 132.740888 98.890294 78.830298 51.076218\n", "22 137.011516 89.778597 63.292471 56.470058\n", "23 137.203025 94.469261 76.878791 62.418852\n", "24 142.344090 88.788008 68.609856 56.361801\n", "25 135.681585 87.898735 68.231739 69.688107\n", "26 140.938870 86.014082 62.370003 57.031428\n", "27 140.725919 90.077822 77.188246 66.063731\n", "28 138.466277 87.430888 76.494054 52.023676\n", "29 140.170639 84.161857 74.864414 64.864676\n", ".. ... ... ... ...\n", "70 136.923241 81.227660 66.117968 59.734647\n", "71 135.694368 97.770688 64.515755 61.152512\n", "72 130.754746 87.812854 64.986135 62.448254\n", "73 141.528819 85.443299 76.717849 62.279392\n", "74 141.519656 90.933897 66.745908 55.648521\n", "75 140.695778 86.746017 73.284271 56.184863\n", "76 141.042892 91.479452 69.141895 64.153969\n", "77 149.032659 85.481779 67.298463 54.970761\n", "78 138.231140 94.998883 73.243940 65.646547\n", "79 137.346696 89.482975 70.499448 58.682914\n", "80 138.165300 88.619963 70.946063 61.444762\n", "81 142.796439 93.984127 65.656375 65.429389\n", "82 138.004608 86.952478 70.308673 53.750816\n", "83 139.899621 84.933594 73.958865 69.729668\n", "84 144.655767 84.507630 60.171290 55.094667\n", "85 145.190858 98.067417 76.512104 58.659214\n", "86 137.745063 86.830467 67.551142 61.260600\n", "87 145.654304 91.807984 74.518208 56.469638\n", "88 134.473530 92.031198 63.850557 59.581589\n", "89 142.730001 93.084033 68.015478 54.936064\n", "90 144.499162 97.420279 67.386408 56.646382\n", "91 136.071159 92.882158 66.362628 57.894079\n", "92 136.213757 89.492170 66.635327 62.421542\n", "93 135.780890 88.002650 71.616357 54.534008\n", "94 141.216893 94.371178 60.230995 52.657605\n", "95 145.379018 88.635882 68.653816 65.730469\n", "96 145.615173 85.831047 62.689592 56.708833\n", "97 144.394473 78.788995 66.989520 63.550746\n", "98 138.403018 89.637459 64.718008 57.934822\n", "99 142.379958 103.710161 70.463281 53.154639\n", "\n", "[100 rows x 4 columns]\n" ] } ], "source": [ "saveData = pandas.DataFrame(systolic_high, columns=['systolic-high'])\n", "saveData['diastolic-high'] = diastolic_high\n", "saveData['systolic-low'] = systolic_low\n", "saveData['diastolic-low'] = diastolic_low\n", "print saveData" ] }, { "cell_type": "code", "execution_count": 106, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " systolic-high diastolic-high systolic-low diastolic-low\n", "0 137.0 90.0 75.610785 58.919102\n", "1 142.0 81.0 60.639671 59.284786\n", "2 143.0 94.0 75.154056 50.423231\n", "3 136.0 98.0 64.290269 56.188862\n", "4 139.0 88.0 67.092255 66.533132\n", "5 138.0 88.0 81.337549 58.624559\n", "6 127.0 91.0 67.841854 66.965385\n", "7 141.0 87.0 61.866278 58.011283\n", "8 129.0 90.0 75.232383 73.269521\n", "9 143.0 90.0 72.333697 63.577845\n", "10 146.0 86.0 74.293820 54.155667\n", "11 135.0 87.0 63.633401 52.308737\n", "12 144.0 88.0 70.935144 63.155199\n", "13 142.0 94.0 71.840943 69.145870\n", "14 150.0 87.0 65.528090 59.315919\n", "15 139.0 92.0 80.373398 59.565634\n", "16 142.0 85.0 61.612864 63.143912\n", "17 144.0 95.0 73.156100 59.764049\n", "18 138.0 91.0 72.361214 60.373349\n", "19 142.0 87.0 65.279445 67.033074\n", "20 140.0 84.0 77.988164 61.760307\n", "21 133.0 99.0 78.830298 51.076218\n", "22 137.0 90.0 63.292471 56.470058\n", "23 137.0 94.0 76.878791 62.418852\n", "24 142.0 89.0 68.609856 56.361801\n", "25 136.0 88.0 68.231739 69.688107\n", "26 141.0 86.0 62.370003 57.031428\n", "27 141.0 90.0 77.188246 66.063731\n", "28 138.0 87.0 76.494054 52.023676\n", "29 140.0 84.0 74.864414 64.864676\n", ".. ... ... ... ...\n", "70 137.0 81.0 66.117968 59.734647\n", "71 136.0 98.0 64.515755 61.152512\n", "72 131.0 88.0 64.986135 62.448254\n", "73 142.0 85.0 76.717849 62.279392\n", "74 142.0 91.0 66.745908 55.648521\n", "75 141.0 87.0 73.284271 56.184863\n", "76 141.0 91.0 69.141895 64.153969\n", "77 149.0 85.0 67.298463 54.970761\n", "78 138.0 95.0 73.243940 65.646547\n", "79 137.0 89.0 70.499448 58.682914\n", "80 138.0 89.0 70.946063 61.444762\n", "81 143.0 94.0 65.656375 65.429389\n", "82 138.0 87.0 70.308673 53.750816\n", "83 140.0 85.0 73.958865 69.729668\n", "84 145.0 85.0 60.171290 55.094667\n", "85 145.0 98.0 76.512104 58.659214\n", "86 138.0 87.0 67.551142 61.260600\n", "87 146.0 92.0 74.518208 56.469638\n", "88 134.0 92.0 63.850557 59.581589\n", "89 143.0 93.0 68.015478 54.936064\n", "90 144.0 97.0 67.386408 56.646382\n", "91 136.0 93.0 66.362628 57.894079\n", "92 136.0 89.0 66.635327 62.421542\n", "93 136.0 88.0 71.616357 54.534008\n", "94 141.0 94.0 60.230995 52.657605\n", "95 145.0 89.0 68.653816 65.730469\n", "96 146.0 86.0 62.689592 56.708833\n", "97 144.0 79.0 66.989520 63.550746\n", "98 138.0 90.0 64.718008 57.934822\n", "99 142.0 104.0 70.463281 53.154639\n", "\n", "[100 rows x 4 columns]\n" ] } ], "source": [ "saveData = saveData.round({'systolic-high':0, 'diastolic-high':0})\n", "print saveData" ] }, { "cell_type": "code", "execution_count": 107, "metadata": { "collapsed": true }, "outputs": [], "source": [ "saveData.to_csv('IntitialData.csv', ',', index=False)" ] }, { "cell_type": "code", "execution_count": 109, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 109, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#plt = saveData.plot(x='systolic-high',kind='hist', normed=True)\n", "saveData['systolic-high'].diff().hist()\n", "# range = np.arange(-4, 4, 0.001)\n", "# plt.plot(range, norm.pdf(range,0,1))\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "plt.show()" ] }, { "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.12" } }, "nbformat": 4, "nbformat_minor": 1 }