```python
import numpy as np
import matplotlib.pyplot as plt
import sympy
```


```python
def f(x):
    return x * x
```


```python
x = np.linspace(-5, 5, num = 100);
print(x)
```

    [-5.         -4.8989899  -4.7979798  -4.6969697  -4.5959596  -4.49494949
     -4.39393939 -4.29292929 -4.19191919 -4.09090909 -3.98989899 -3.88888889
     -3.78787879 -3.68686869 -3.58585859 -3.48484848 -3.38383838 -3.28282828
     -3.18181818 -3.08080808 -2.97979798 -2.87878788 -2.77777778 -2.67676768
     -2.57575758 -2.47474747 -2.37373737 -2.27272727 -2.17171717 -2.07070707
     -1.96969697 -1.86868687 -1.76767677 -1.66666667 -1.56565657 -1.46464646
     -1.36363636 -1.26262626 -1.16161616 -1.06060606 -0.95959596 -0.85858586
     -0.75757576 -0.65656566 -0.55555556 -0.45454545 -0.35353535 -0.25252525
     -0.15151515 -0.05050505  0.05050505  0.15151515  0.25252525  0.35353535
      0.45454545  0.55555556  0.65656566  0.75757576  0.85858586  0.95959596
      1.06060606  1.16161616  1.26262626  1.36363636  1.46464646  1.56565657
      1.66666667  1.76767677  1.86868687  1.96969697  2.07070707  2.17171717
      2.27272727  2.37373737  2.47474747  2.57575758  2.67676768  2.77777778
      2.87878788  2.97979798  3.08080808  3.18181818  3.28282828  3.38383838
      3.48484848  3.58585859  3.68686869  3.78787879  3.88888889  3.98989899
      4.09090909  4.19191919  4.29292929  4.39393939  4.49494949  4.5959596
      4.6969697   4.7979798   4.8989899   5.        ]



```python
y = f(x)
print(y)
```

    [  2.50000000e+01   2.40001020e+01   2.30206101e+01   2.20615243e+01
       2.11228446e+01   2.02045710e+01   1.93067034e+01   1.84292419e+01
       1.75721865e+01   1.67355372e+01   1.59192939e+01   1.51234568e+01
       1.43480257e+01   1.35930007e+01   1.28583818e+01   1.21441690e+01
       1.14503622e+01   1.07769615e+01   1.01239669e+01   9.49137843e+00
       8.87919600e+00   8.28741965e+00   7.71604938e+00   7.16508520e+00
       6.63452709e+00   6.12437506e+00   5.63462912e+00   5.16528926e+00
       4.71635547e+00   4.28782777e+00   3.87970615e+00   3.49199061e+00
       3.12468115e+00   2.77777778e+00   2.45128048e+00   2.14518927e+00
       1.85950413e+00   1.59422508e+00   1.34935211e+00   1.12488522e+00
       9.20824406e-01   7.37169677e-01   5.73921028e-01   4.31078461e-01
       3.08641975e-01   2.06611570e-01   1.24987246e-01   6.37690032e-02
       2.29568411e-02   2.55076013e-03   2.55076013e-03   2.29568411e-02
       6.37690032e-02   1.24987246e-01   2.06611570e-01   3.08641975e-01
       4.31078461e-01   5.73921028e-01   7.37169677e-01   9.20824406e-01
       1.12488522e+00   1.34935211e+00   1.59422508e+00   1.85950413e+00
       2.14518927e+00   2.45128048e+00   2.77777778e+00   3.12468115e+00
       3.49199061e+00   3.87970615e+00   4.28782777e+00   4.71635547e+00
       5.16528926e+00   5.63462912e+00   6.12437506e+00   6.63452709e+00
       7.16508520e+00   7.71604938e+00   8.28741965e+00   8.87919600e+00
       9.49137843e+00   1.01239669e+01   1.07769615e+01   1.14503622e+01
       1.21441690e+01   1.28583818e+01   1.35930007e+01   1.43480257e+01
       1.51234568e+01   1.59192939e+01   1.67355372e+01   1.75721865e+01
       1.84292419e+01   1.93067034e+01   2.02045710e+01   2.11228446e+01
       2.20615243e+01   2.30206101e+01   2.40001020e+01   2.50000000e+01]



```python
plt.plot(x, y)
plt.show()
```


```python
plt.plot(x, np.exp(x))
plt.show()
```


```python
import pandas as pd
```


```python
dat = pd.read_csv('../r_playground/mice_pheno.csv')
```


```python
dat.head()
```




<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>Sex</th>
      <th>Diet</th>
      <th>Bodyweight</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>F</td>
      <td>hf</td>
      <td>31.94</td>
    </tr>
    <tr>
      <th>1</th>
      <td>F</td>
      <td>hf</td>
      <td>32.48</td>
    </tr>
    <tr>
      <th>2</th>
      <td>F</td>
      <td>hf</td>
      <td>22.82</td>
    </tr>
    <tr>
      <th>3</th>
      <td>F</td>
      <td>hf</td>
      <td>19.92</td>
    </tr>
    <tr>
      <th>4</th>
      <td>F</td>
      <td>hf</td>
      <td>32.22</td>
    </tr>
  </tbody>
</table>
</div>




```python
hf = (dat.Diet == 'hf')
```


```python
type(hf)
```




    pandas.core.series.Series




```python
fm = (dat.Sex == 'F')
```


```python
# element-wise logical operator
# and -- &
# or -- |
# not -- ~
hfPopulation = dat.Bodyweight[hf & fm]
```


```python
hfPopulation.size
```




    200




```python
chow = dat.Diet == 'chow'
controlPopulation = dat.Bodyweight[chow & fm]
print(controlPopulation.size)
```

    225



```python
print(dat.size)
print(dat.count())
print(dat.Sex.size)
print(dat.Sex.count())
```

    2538
    Sex           846
    Diet          846
    Bodyweight    841
    dtype: int64
    846
    846



```python
c = np.zeros(10000);
for i in range(10000):
    c[i] = (controlPopulation.sample(12)).mean() - (hfPopulation.sample(12)).mean()
    
print(c)
```

    [-2.05166667  2.26666667 -5.17083333 ..., -2.81416667 -2.24166667 -0.98      ]



```python

```

9c5cdf485d293f4f6edb405d04fc322960547a45
ipynb
Jupyter Notebook
practicing numpy.ipynb
mingzhangyang/learning_pandas
6ec0ef09839d87a28dbf3beaa7c61e89f4346a36
Apache-2.0
practicing numpy.ipynb
mingzhangyang/learning_pandas
6ec0ef09839d87a28dbf3beaa7c61e89f4346a36
Apache-2.0
practicing numpy.ipynb
mingzhangyang/learning_pandas
6ec0ef09839d87a28dbf3beaa7c61e89f4346a36
Apache-2.0
2017-10-10T15:09:38.000Z
2017-10-10T15:09:38.000Z
Qwen/Qwen-72B
1. YES
2. YES