線形重回帰を本当はPythonで解きたいけど表計算で解けと言われたので


<a href="https://qiita.com/maskot1977/items/97b3c3f0f3d35d5f162a">線形回帰を本当はPythonで解きたいけど表計算で解けと言われたので</a>の続編です。

# 用いるデータ

今回も<a href="http://mh.rgr.jp/memo/mq0111.htm" target="_blank">分子性物質のデータ（融点・沸点）</a>を使います。前回は分子量だけを使って沸点を予測しようという無理ゲーでしたが、今度は分子量だけでなく双極子モーメントも使って沸点を予測してみましょう。


```python
import pandas as pd
data = [['HF', 19.5, 20.0, 1.826567],
        ['HCl', -84.9, 36.5, 1.1086],
        ['HBr', -67.0, 80.9, 0.8271],
        ['HI', -35.1, 127.9, 0.4477],
        ['H2O', 100.0, 18.0, 1.8546],
        ['H2S', -60.7, 34.1, 0.978325],
        ['H2Se', -42, 81.0, 0.627],
        ['NH3', -33.4, 17.0, 1.471772],
        ['PH3', -87, 34.0, 0.57397],
        ['AsH3', -55, 77.9, 0.217],
        ['SbH3', -17.1, 124.8, 0.116],
        ['CH4', -161.49, 16.0, 0],
        ['SiH4', -111.8, 32.1, 0],
        ['GeH4', -90, 76.6, 0],
        ['SnH4', -52, 122.7, 0],
        ['He', -268.934, 4.0, 0],
        ['Ne', -246.048, 20.2, 0],
        ['Ar', -185.7, 39.9, 0],
        ['Kr', -152.3, 83.8, 0],
        ['Xe', -108.1, 131.3, 0],
       ]
df = pd.DataFrame(data, columns = ['molecule', 'boiling point', 'molecular weight', 'dipole monent'])
df
```




<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>molecule</th>
      <th>boiling point</th>
      <th>molecular weight</th>
      <th>dipole monent</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>HF</td>
      <td>19.500</td>
      <td>20.0</td>
      <td>1.826567</td>
    </tr>
    <tr>
      <th>1</th>
      <td>HCl</td>
      <td>-84.900</td>
      <td>36.5</td>
      <td>1.108600</td>
    </tr>
    <tr>
      <th>2</th>
      <td>HBr</td>
      <td>-67.000</td>
      <td>80.9</td>
      <td>0.827100</td>
    </tr>
    <tr>
      <th>3</th>
      <td>HI</td>
      <td>-35.100</td>
      <td>127.9</td>
      <td>0.447700</td>
    </tr>
    <tr>
      <th>4</th>
      <td>H2O</td>
      <td>100.000</td>
      <td>18.0</td>
      <td>1.854600</td>
    </tr>
    <tr>
      <th>5</th>
      <td>H2S</td>
      <td>-60.700</td>
      <td>34.1</td>
      <td>0.978325</td>
    </tr>
    <tr>
      <th>6</th>
      <td>H2Se</td>
      <td>-42.000</td>
      <td>81.0</td>
      <td>0.627000</td>
    </tr>
    <tr>
      <th>7</th>
      <td>NH3</td>
      <td>-33.400</td>
      <td>17.0</td>
      <td>1.471772</td>
    </tr>
    <tr>
      <th>8</th>
      <td>PH3</td>
      <td>-87.000</td>
      <td>34.0</td>
      <td>0.573970</td>
    </tr>
    <tr>
      <th>9</th>
      <td>AsH3</td>
      <td>-55.000</td>
      <td>77.9</td>
      <td>0.217000</td>
    </tr>
    <tr>
      <th>10</th>
      <td>SbH3</td>
      <td>-17.100</td>
      <td>124.8</td>
      <td>0.116000</td>
    </tr>
    <tr>
      <th>11</th>
      <td>CH4</td>
      <td>-161.490</td>
      <td>16.0</td>
      <td>0.000000</td>
    </tr>
    <tr>
      <th>12</th>
      <td>SiH4</td>
      <td>-111.800</td>
      <td>32.1</td>
      <td>0.000000</td>
    </tr>
    <tr>
      <th>13</th>
      <td>GeH4</td>
      <td>-90.000</td>
      <td>76.6</td>
      <td>0.000000</td>
    </tr>
    <tr>
      <th>14</th>
      <td>SnH4</td>
      <td>-52.000</td>
      <td>122.7</td>
      <td>0.000000</td>
    </tr>
    <tr>
      <th>15</th>
      <td>He</td>
      <td>-268.934</td>
      <td>4.0</td>
      <td>0.000000</td>
    </tr>
    <tr>
      <th>16</th>
      <td>Ne</td>
      <td>-246.048</td>
      <td>20.2</td>
      <td>0.000000</td>
    </tr>
    <tr>
      <th>17</th>
      <td>Ar</td>
      <td>-185.700</td>
      <td>39.9</td>
      <td>0.000000</td>
    </tr>
    <tr>
      <th>18</th>
      <td>Kr</td>
      <td>-152.300</td>
      <td>83.8</td>
      <td>0.000000</td>
    </tr>
    <tr>
      <th>19</th>
      <td>Xe</td>
      <td>-108.100</td>
      <td>131.3</td>
      <td>0.000000</td>
    </tr>
  </tbody>
</table>
</div>



説明変数Xは以下のようになります。


```python
X = df.loc[:, ['molecular weight', 'dipole monent']].as_matrix()
X
```




    array([[  2.00000000e+01,   1.82656700e+00],
           [  3.65000000e+01,   1.10860000e+00],
           [  8.09000000e+01,   8.27100000e-01],
           [  1.27900000e+02,   4.47700000e-01],
           [  1.80000000e+01,   1.85460000e+00],
           [  3.41000000e+01,   9.78325000e-01],
           [  8.10000000e+01,   6.27000000e-01],
           [  1.70000000e+01,   1.47177200e+00],
           [  3.40000000e+01,   5.73970000e-01],
           [  7.79000000e+01,   2.17000000e-01],
           [  1.24800000e+02,   1.16000000e-01],
           [  1.60000000e+01,   0.00000000e+00],
           [  3.21000000e+01,   0.00000000e+00],
           [  7.66000000e+01,   0.00000000e+00],
           [  1.22700000e+02,   0.00000000e+00],
           [  4.00000000e+00,   0.00000000e+00],
           [  2.02000000e+01,   0.00000000e+00],
           [  3.99000000e+01,   0.00000000e+00],
           [  8.38000000e+01,   0.00000000e+00],
           [  1.31300000e+02,   0.00000000e+00]])



目的変数yは前回と同じ、沸点です。


```python
Y = df['boiling point'].as_matrix()
Y
```




    array([  19.5  ,  -84.9  ,  -67.   ,  -35.1  ,  100.   ,  -60.7  ,
            -42.   ,  -33.4  ,  -87.   ,  -55.   ,  -17.1  , -161.49 ,
           -111.8  ,  -90.   ,  -52.   , -268.934, -246.048, -185.7  ,
           -152.3  , -108.1  ])



沸点、分子量、双極子モーメントがどのような関係にあるか散布図行列で概観してみましょう。


```python
%matplotlib inline
import matplotlib.pyplot as plt
from pandas.tools.plotting import *
scatter_matrix(df)
plt.show()
```


![重回帰を本当はPythonで解きたいけど表計算で解けと言われたので_7_0.png](https://qiita-image-store.s3.amazonaws.com/0/211162/d9b9cc81-7ded-f9f2-88a5-2f9e1a1b4961.png)



# まずは一番便利な scikit-learn から

前回、scikit-learnを使えば簡単に線形回帰できることをお示ししました。変数が増えて線形重回帰になっても、ほとんど手間が増えません。そう、scikit-learnならね。


```python
from sklearn import linear_model
lr = linear_model.LinearRegression()
```


```python
lr.fit(X, Y)
```




    LinearRegression(copy_X=True, fit_intercept=True, n_jobs=1, normalize=False)




```python
# 回帰係数
lr.coef_
```




    array([   1.17775083,  124.38195483])




```python
# 切片
lr.intercept_
```




    -218.85778226168119




```python
print("y = f(x) = w1x1 + w2x2 + t; (w1, w2, t) = ({0}, {1}, {2})".format(lr.coef_[0], lr.coef_[1], lr.intercept_))
```

    y = f(x) = w1x1 + w2x2 + t; (w1, w2, t) = (1.1777508314139944, 124.38195482549655, -218.8577822616812)



```python
# 決定係数
lr.score(X, Y)
```




    0.78084985722905187




```python
lr.predict([200, 0.5])
```




    array([ 78.88336143])




```python
lr.predict([[150, 0], [100, 1.0]])
```




    array([-42.19515755,  23.29925571])



# 次は、ガチPythonで。

scikit-learnを使わずにガチPythonで解こうと思うと、少し大変ですね。頑張ってみましょう。


```python
# 平均値を求める関数
def mean(list):
    sum = 0
    for x in list:
        sum += x
    return sum / len(list)
```


```python
# 分散を求める関数
def variance(list):
    ave = mean(list)
    sum = 0
    for x in list:
        sum += (x - ave) ** 2
    return sum / len(list)
```


```python
# 標準偏差を求める関数
import math
def standard_deviation(list):
    return math.sqrt(variance(list))
```


```python
# 共分散 = 偏差積の平均
def covariance(list1, list2): 
    mean1 = mean(list1)
    mean2 = mean(list2)
    sum = 0
    for d1, d2 in zip(list1, list2):
        sum += (d1 - mean1) * (d2 - mean2)
    return sum / len(list1)
```


```python
# 相関係数 = 共分散を list1, list2 の標準偏差で割ったもの
def correlation(list1, list2):
    return covariance(list1, list2) / (standard_deviation(list1) * standard_deviation(list2))
```


```python
# a の影響を除いた、b と y の偏回帰係数 partial regression coefficient を求める関数
def partial_regression(a, b, y):
    rby = correlation(b, y)
    ray = correlation(a, y)
    rab = correlation(a, b)
    return (rby - ray * rab) * standard_deviation(y) / ((1 - rab ** 2) * standard_deviation(b))
```


```python
# 定数 w1 = （x2 の影響を除いた、x1 と y の偏回帰係数）
w1 = partial_regression(X[:, 1], X[:, 0], Y)
```


```python
# 定数 w2 = （x1 の影響を除いた、x2 と y の偏回帰係数）
w2 = partial_regression(X[:, 0], X[:, 1], Y)
```


```python
# 定数 t　＝　yの平均　－　w1*x1の平均　－　w2*x2の平均
t = mean(Y) - w1 * mean(X[:, 0]) - w2 * mean(X[:, 1])
```


```python
# 回帰直線の式を表示
print("y = f(x) = w1x1 + w2x2 + t; (w1, w2, t) = ({0}, {1}, {2})".format(w1, w2, t))
```

    y = f(x) = w1x1 + w2x2 + t; (w1, w2, t) = (1.1777508314139928, 124.38195482549644, -218.85778226168105)



```python
def f(X):
    return w1 * X[:, 0] + w2 * X[:, 1] + t
```


```python
r2 = 1. - sum((Y - f(X))**2) / sum((Y - mean(Y))**2)
r2
```




    0.78084985722905187



# さて、表計算で解けと言われたので pandas で書いてみましょうか。

二度とやりたくないくらい大変です。さあどうぞ。


```python
import copy
from IPython.display import display
excel = copy.deepcopy(df)
excel
```




<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>molecule</th>
      <th>boiling point</th>
      <th>molecular weight</th>
      <th>dipole monent</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>HF</td>
      <td>19.500</td>
      <td>20.0</td>
      <td>1.826567</td>
    </tr>
    <tr>
      <th>1</th>
      <td>HCl</td>
      <td>-84.900</td>
      <td>36.5</td>
      <td>1.108600</td>
    </tr>
    <tr>
      <th>2</th>
      <td>HBr</td>
      <td>-67.000</td>
      <td>80.9</td>
      <td>0.827100</td>
    </tr>
    <tr>
      <th>3</th>
      <td>HI</td>
      <td>-35.100</td>
      <td>127.9</td>
      <td>0.447700</td>
    </tr>
    <tr>
      <th>4</th>
      <td>H2O</td>
      <td>100.000</td>
      <td>18.0</td>
      <td>1.854600</td>
    </tr>
    <tr>
      <th>5</th>
      <td>H2S</td>
      <td>-60.700</td>
      <td>34.1</td>
      <td>0.978325</td>
    </tr>
    <tr>
      <th>6</th>
      <td>H2Se</td>
      <td>-42.000</td>
      <td>81.0</td>
      <td>0.627000</td>
    </tr>
    <tr>
      <th>7</th>
      <td>NH3</td>
      <td>-33.400</td>
      <td>17.0</td>
      <td>1.471772</td>
    </tr>
    <tr>
      <th>8</th>
      <td>PH3</td>
      <td>-87.000</td>
      <td>34.0</td>
      <td>0.573970</td>
    </tr>
    <tr>
      <th>9</th>
      <td>AsH3</td>
      <td>-55.000</td>
      <td>77.9</td>
      <td>0.217000</td>
    </tr>
    <tr>
      <th>10</th>
      <td>SbH3</td>
      <td>-17.100</td>
      <td>124.8</td>
      <td>0.116000</td>
    </tr>
    <tr>
      <th>11</th>
      <td>CH4</td>
      <td>-161.490</td>
      <td>16.0</td>
      <td>0.000000</td>
    </tr>
    <tr>
      <th>12</th>
      <td>SiH4</td>
      <td>-111.800</td>
      <td>32.1</td>
      <td>0.000000</td>
    </tr>
    <tr>
      <th>13</th>
      <td>GeH4</td>
      <td>-90.000</td>
      <td>76.6</td>
      <td>0.000000</td>
    </tr>
    <tr>
      <th>14</th>
      <td>SnH4</td>
      <td>-52.000</td>
      <td>122.7</td>
      <td>0.000000</td>
    </tr>
    <tr>
      <th>15</th>
      <td>He</td>
      <td>-268.934</td>
      <td>4.0</td>
      <td>0.000000</td>
    </tr>
    <tr>
      <th>16</th>
      <td>Ne</td>
      <td>-246.048</td>
      <td>20.2</td>
      <td>0.000000</td>
    </tr>
    <tr>
      <th>17</th>
      <td>Ar</td>
      <td>-185.700</td>
      <td>39.9</td>
      <td>0.000000</td>
    </tr>
    <tr>
      <th>18</th>
      <td>Kr</td>
      <td>-152.300</td>
      <td>83.8</td>
      <td>0.000000</td>
    </tr>
    <tr>
      <th>19</th>
      <td>Xe</td>
      <td>-108.100</td>
      <td>131.3</td>
      <td>0.000000</td>
    </tr>
  </tbody>
</table>
</div>




```python
excel['y'] = excel['boiling point']
excel['x1'] = excel['molecular weight']
excel['x2'] = excel['dipole monent']
mean_y = mean(excel['y'])
mean_x1 = mean(excel['x1'])
mean_x2 = mean(excel['x2'])
display(excel, pd.DataFrame([[mean_y, mean_x1, mean_x2]], columns=['y','x1', 'x2'], index=['mean']))
```


<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>molecule</th>
      <th>boiling point</th>
      <th>molecular weight</th>
      <th>dipole monent</th>
      <th>y</th>
      <th>x1</th>
      <th>x2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>HF</td>
      <td>19.500</td>
      <td>20.0</td>
      <td>1.826567</td>
      <td>19.500</td>
      <td>20.0</td>
      <td>1.826567</td>
    </tr>
    <tr>
      <th>1</th>
      <td>HCl</td>
      <td>-84.900</td>
      <td>36.5</td>
      <td>1.108600</td>
      <td>-84.900</td>
      <td>36.5</td>
      <td>1.108600</td>
    </tr>
    <tr>
      <th>2</th>
      <td>HBr</td>
      <td>-67.000</td>
      <td>80.9</td>
      <td>0.827100</td>
      <td>-67.000</td>
      <td>80.9</td>
      <td>0.827100</td>
    </tr>
    <tr>
      <th>3</th>
      <td>HI</td>
      <td>-35.100</td>
      <td>127.9</td>
      <td>0.447700</td>
      <td>-35.100</td>
      <td>127.9</td>
      <td>0.447700</td>
    </tr>
    <tr>
      <th>4</th>
      <td>H2O</td>
      <td>100.000</td>
      <td>18.0</td>
      <td>1.854600</td>
      <td>100.000</td>
      <td>18.0</td>
      <td>1.854600</td>
    </tr>
    <tr>
      <th>5</th>
      <td>H2S</td>
      <td>-60.700</td>
      <td>34.1</td>
      <td>0.978325</td>
      <td>-60.700</td>
      <td>34.1</td>
      <td>0.978325</td>
    </tr>
    <tr>
      <th>6</th>
      <td>H2Se</td>
      <td>-42.000</td>
      <td>81.0</td>
      <td>0.627000</td>
      <td>-42.000</td>
      <td>81.0</td>
      <td>0.627000</td>
    </tr>
    <tr>
      <th>7</th>
      <td>NH3</td>
      <td>-33.400</td>
      <td>17.0</td>
      <td>1.471772</td>
      <td>-33.400</td>
      <td>17.0</td>
      <td>1.471772</td>
    </tr>
    <tr>
      <th>8</th>
      <td>PH3</td>
      <td>-87.000</td>
      <td>34.0</td>
      <td>0.573970</td>
      <td>-87.000</td>
      <td>34.0</td>
      <td>0.573970</td>
    </tr>
    <tr>
      <th>9</th>
      <td>AsH3</td>
      <td>-55.000</td>
      <td>77.9</td>
      <td>0.217000</td>
      <td>-55.000</td>
      <td>77.9</td>
      <td>0.217000</td>
    </tr>
    <tr>
      <th>10</th>
      <td>SbH3</td>
      <td>-17.100</td>
      <td>124.8</td>
      <td>0.116000</td>
      <td>-17.100</td>
      <td>124.8</td>
      <td>0.116000</td>
    </tr>
    <tr>
      <th>11</th>
      <td>CH4</td>
      <td>-161.490</td>
      <td>16.0</td>
      <td>0.000000</td>
      <td>-161.490</td>
      <td>16.0</td>
      <td>0.000000</td>
    </tr>
    <tr>
      <th>12</th>
      <td>SiH4</td>
      <td>-111.800</td>
      <td>32.1</td>
      <td>0.000000</td>
      <td>-111.800</td>
      <td>32.1</td>
      <td>0.000000</td>
    </tr>
    <tr>
      <th>13</th>
      <td>GeH4</td>
      <td>-90.000</td>
      <td>76.6</td>
      <td>0.000000</td>
      <td>-90.000</td>
      <td>76.6</td>
      <td>0.000000</td>
    </tr>
    <tr>
      <th>14</th>
      <td>SnH4</td>
      <td>-52.000</td>
      <td>122.7</td>
      <td>0.000000</td>
      <td>-52.000</td>
      <td>122.7</td>
      <td>0.000000</td>
    </tr>
    <tr>
      <th>15</th>
      <td>He</td>
      <td>-268.934</td>
      <td>4.0</td>
      <td>0.000000</td>
      <td>-268.934</td>
      <td>4.0</td>
      <td>0.000000</td>
    </tr>
    <tr>
      <th>16</th>
      <td>Ne</td>
      <td>-246.048</td>
      <td>20.2</td>
      <td>0.000000</td>
      <td>-246.048</td>
      <td>20.2</td>
      <td>0.000000</td>
    </tr>
    <tr>
      <th>17</th>
      <td>Ar</td>
      <td>-185.700</td>
      <td>39.9</td>
      <td>0.000000</td>
      <td>-185.700</td>
      <td>39.9</td>
      <td>0.000000</td>
    </tr>
    <tr>
      <th>18</th>
      <td>Kr</td>
      <td>-152.300</td>
      <td>83.8</td>
      <td>0.000000</td>
      <td>-152.300</td>
      <td>83.8</td>
      <td>0.000000</td>
    </tr>
    <tr>
      <th>19</th>
      <td>Xe</td>
      <td>-108.100</td>
      <td>131.3</td>
      <td>0.000000</td>
      <td>-108.100</td>
      <td>131.3</td>
      <td>0.000000</td>
    </tr>
  </tbody>
</table>
</div>



<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>y</th>
      <th>x1</th>
      <th>x2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>mean</th>
      <td>-86.9536</td>
      <td>58.935</td>
      <td>0.502432</td>
    </tr>
  </tbody>
</table>
</div>



```python
excel['y-mean(y)'] = [y - mean_y for y in excel['y']]
excel['x1-mean(x1)'] = [x1 - mean_x1 for x1 in excel['x1']]
excel['x2-mean(x2)'] = [x2 - mean_x2 for x2 in excel['x2']]
display(excel, pd.DataFrame([[mean_y, mean_x1, mean_x2]], columns=['y','x1', 'x2'], index=['mean']))
```


<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>molecule</th>
      <th>boiling point</th>
      <th>molecular weight</th>
      <th>dipole monent</th>
      <th>y</th>
      <th>x1</th>
      <th>x2</th>
      <th>y-mean(y)</th>
      <th>x1-mean(x1)</th>
      <th>x2-mean(x2)</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>HF</td>
      <td>19.500</td>
      <td>20.0</td>
      <td>1.826567</td>
      <td>19.500</td>
      <td>20.0</td>
      <td>1.826567</td>
      <td>106.4536</td>
      <td>-38.935</td>
      <td>1.324135</td>
    </tr>
    <tr>
      <th>1</th>
      <td>HCl</td>
      <td>-84.900</td>
      <td>36.5</td>
      <td>1.108600</td>
      <td>-84.900</td>
      <td>36.5</td>
      <td>1.108600</td>
      <td>2.0536</td>
      <td>-22.435</td>
      <td>0.606168</td>
    </tr>
    <tr>
      <th>2</th>
      <td>HBr</td>
      <td>-67.000</td>
      <td>80.9</td>
      <td>0.827100</td>
      <td>-67.000</td>
      <td>80.9</td>
      <td>0.827100</td>
      <td>19.9536</td>
      <td>21.965</td>
      <td>0.324668</td>
    </tr>
    <tr>
      <th>3</th>
      <td>HI</td>
      <td>-35.100</td>
      <td>127.9</td>
      <td>0.447700</td>
      <td>-35.100</td>
      <td>127.9</td>
      <td>0.447700</td>
      <td>51.8536</td>
      <td>68.965</td>
      <td>-0.054732</td>
    </tr>
    <tr>
      <th>4</th>
      <td>H2O</td>
      <td>100.000</td>
      <td>18.0</td>
      <td>1.854600</td>
      <td>100.000</td>
      <td>18.0</td>
      <td>1.854600</td>
      <td>186.9536</td>
      <td>-40.935</td>
      <td>1.352168</td>
    </tr>
    <tr>
      <th>5</th>
      <td>H2S</td>
      <td>-60.700</td>
      <td>34.1</td>
      <td>0.978325</td>
      <td>-60.700</td>
      <td>34.1</td>
      <td>0.978325</td>
      <td>26.2536</td>
      <td>-24.835</td>
      <td>0.475893</td>
    </tr>
    <tr>
      <th>6</th>
      <td>H2Se</td>
      <td>-42.000</td>
      <td>81.0</td>
      <td>0.627000</td>
      <td>-42.000</td>
      <td>81.0</td>
      <td>0.627000</td>
      <td>44.9536</td>
      <td>22.065</td>
      <td>0.124568</td>
    </tr>
    <tr>
      <th>7</th>
      <td>NH3</td>
      <td>-33.400</td>
      <td>17.0</td>
      <td>1.471772</td>
      <td>-33.400</td>
      <td>17.0</td>
      <td>1.471772</td>
      <td>53.5536</td>
      <td>-41.935</td>
      <td>0.969340</td>
    </tr>
    <tr>
      <th>8</th>
      <td>PH3</td>
      <td>-87.000</td>
      <td>34.0</td>
      <td>0.573970</td>
      <td>-87.000</td>
      <td>34.0</td>
      <td>0.573970</td>
      <td>-0.0464</td>
      <td>-24.935</td>
      <td>0.071538</td>
    </tr>
    <tr>
      <th>9</th>
      <td>AsH3</td>
      <td>-55.000</td>
      <td>77.9</td>
      <td>0.217000</td>
      <td>-55.000</td>
      <td>77.9</td>
      <td>0.217000</td>
      <td>31.9536</td>
      <td>18.965</td>
      <td>-0.285432</td>
    </tr>
    <tr>
      <th>10</th>
      <td>SbH3</td>
      <td>-17.100</td>
      <td>124.8</td>
      <td>0.116000</td>
      <td>-17.100</td>
      <td>124.8</td>
      <td>0.116000</td>
      <td>69.8536</td>
      <td>65.865</td>
      <td>-0.386432</td>
    </tr>
    <tr>
      <th>11</th>
      <td>CH4</td>
      <td>-161.490</td>
      <td>16.0</td>
      <td>0.000000</td>
      <td>-161.490</td>
      <td>16.0</td>
      <td>0.000000</td>
      <td>-74.5364</td>
      <td>-42.935</td>
      <td>-0.502432</td>
    </tr>
    <tr>
      <th>12</th>
      <td>SiH4</td>
      <td>-111.800</td>
      <td>32.1</td>
      <td>0.000000</td>
      <td>-111.800</td>
      <td>32.1</td>
      <td>0.000000</td>
      <td>-24.8464</td>
      <td>-26.835</td>
      <td>-0.502432</td>
    </tr>
    <tr>
      <th>13</th>
      <td>GeH4</td>
      <td>-90.000</td>
      <td>76.6</td>
      <td>0.000000</td>
      <td>-90.000</td>
      <td>76.6</td>
      <td>0.000000</td>
      <td>-3.0464</td>
      <td>17.665</td>
      <td>-0.502432</td>
    </tr>
    <tr>
      <th>14</th>
      <td>SnH4</td>
      <td>-52.000</td>
      <td>122.7</td>
      <td>0.000000</td>
      <td>-52.000</td>
      <td>122.7</td>
      <td>0.000000</td>
      <td>34.9536</td>
      <td>63.765</td>
      <td>-0.502432</td>
    </tr>
    <tr>
      <th>15</th>
      <td>He</td>
      <td>-268.934</td>
      <td>4.0</td>
      <td>0.000000</td>
      <td>-268.934</td>
      <td>4.0</td>
      <td>0.000000</td>
      <td>-181.9804</td>
      <td>-54.935</td>
      <td>-0.502432</td>
    </tr>
    <tr>
      <th>16</th>
      <td>Ne</td>
      <td>-246.048</td>
      <td>20.2</td>
      <td>0.000000</td>
      <td>-246.048</td>
      <td>20.2</td>
      <td>0.000000</td>
      <td>-159.0944</td>
      <td>-38.735</td>
      <td>-0.502432</td>
    </tr>
    <tr>
      <th>17</th>
      <td>Ar</td>
      <td>-185.700</td>
      <td>39.9</td>
      <td>0.000000</td>
      <td>-185.700</td>
      <td>39.9</td>
      <td>0.000000</td>
      <td>-98.7464</td>
      <td>-19.035</td>
      <td>-0.502432</td>
    </tr>
    <tr>
      <th>18</th>
      <td>Kr</td>
      <td>-152.300</td>
      <td>83.8</td>
      <td>0.000000</td>
      <td>-152.300</td>
      <td>83.8</td>
      <td>0.000000</td>
      <td>-65.3464</td>
      <td>24.865</td>
      <td>-0.502432</td>
    </tr>
    <tr>
      <th>19</th>
      <td>Xe</td>
      <td>-108.100</td>
      <td>131.3</td>
      <td>0.000000</td>
      <td>-108.100</td>
      <td>131.3</td>
      <td>0.000000</td>
      <td>-21.1464</td>
      <td>72.365</td>
      <td>-0.502432</td>
    </tr>
  </tbody>
</table>
</div>



<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>y</th>
      <th>x1</th>
      <th>x2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>mean</th>
      <td>-86.9536</td>
      <td>58.935</td>
      <td>0.502432</td>
    </tr>
  </tbody>
</table>
</div>



```python
excel['(y-mean(y))**2'] = [sa ** 2 for sa in excel['y-mean(y)']]
excel['(x1-mean(x1))**2'] = [sa ** 2 for sa in excel['x1-mean(x1)']]
excel['(x2-mean(x2))**2'] = [sa ** 2 for sa in excel['x2-mean(x2)']]
display(excel, pd.DataFrame([[mean_y, mean_x1, mean_x2]], columns=['y','x1', 'x2'], index=['mean']))
```


<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>molecule</th>
      <th>boiling point</th>
      <th>molecular weight</th>
      <th>dipole monent</th>
      <th>y</th>
      <th>x1</th>
      <th>x2</th>
      <th>y-mean(y)</th>
      <th>x1-mean(x1)</th>
      <th>x2-mean(x2)</th>
      <th>(y-mean(y))**2</th>
      <th>(x1-mean(x1))**2</th>
      <th>(x2-mean(x2))**2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>HF</td>
      <td>19.500</td>
      <td>20.0</td>
      <td>1.826567</td>
      <td>19.500</td>
      <td>20.0</td>
      <td>1.826567</td>
      <td>106.4536</td>
      <td>-38.935</td>
      <td>1.324135</td>
      <td>11332.368953</td>
      <td>1515.934225</td>
      <td>1.753334</td>
    </tr>
    <tr>
      <th>1</th>
      <td>HCl</td>
      <td>-84.900</td>
      <td>36.5</td>
      <td>1.108600</td>
      <td>-84.900</td>
      <td>36.5</td>
      <td>1.108600</td>
      <td>2.0536</td>
      <td>-22.435</td>
      <td>0.606168</td>
      <td>4.217273</td>
      <td>503.329225</td>
      <td>0.367440</td>
    </tr>
    <tr>
      <th>2</th>
      <td>HBr</td>
      <td>-67.000</td>
      <td>80.9</td>
      <td>0.827100</td>
      <td>-67.000</td>
      <td>80.9</td>
      <td>0.827100</td>
      <td>19.9536</td>
      <td>21.965</td>
      <td>0.324668</td>
      <td>398.146153</td>
      <td>482.461225</td>
      <td>0.105410</td>
    </tr>
    <tr>
      <th>3</th>
      <td>HI</td>
      <td>-35.100</td>
      <td>127.9</td>
      <td>0.447700</td>
      <td>-35.100</td>
      <td>127.9</td>
      <td>0.447700</td>
      <td>51.8536</td>
      <td>68.965</td>
      <td>-0.054732</td>
      <td>2688.795833</td>
      <td>4756.171225</td>
      <td>0.002996</td>
    </tr>
    <tr>
      <th>4</th>
      <td>H2O</td>
      <td>100.000</td>
      <td>18.0</td>
      <td>1.854600</td>
      <td>100.000</td>
      <td>18.0</td>
      <td>1.854600</td>
      <td>186.9536</td>
      <td>-40.935</td>
      <td>1.352168</td>
      <td>34951.648553</td>
      <td>1675.674225</td>
      <td>1.828359</td>
    </tr>
    <tr>
      <th>5</th>
      <td>H2S</td>
      <td>-60.700</td>
      <td>34.1</td>
      <td>0.978325</td>
      <td>-60.700</td>
      <td>34.1</td>
      <td>0.978325</td>
      <td>26.2536</td>
      <td>-24.835</td>
      <td>0.475893</td>
      <td>689.251513</td>
      <td>616.777225</td>
      <td>0.226474</td>
    </tr>
    <tr>
      <th>6</th>
      <td>H2Se</td>
      <td>-42.000</td>
      <td>81.0</td>
      <td>0.627000</td>
      <td>-42.000</td>
      <td>81.0</td>
      <td>0.627000</td>
      <td>44.9536</td>
      <td>22.065</td>
      <td>0.124568</td>
      <td>2020.826153</td>
      <td>486.864225</td>
      <td>0.015517</td>
    </tr>
    <tr>
      <th>7</th>
      <td>NH3</td>
      <td>-33.400</td>
      <td>17.0</td>
      <td>1.471772</td>
      <td>-33.400</td>
      <td>17.0</td>
      <td>1.471772</td>
      <td>53.5536</td>
      <td>-41.935</td>
      <td>0.969340</td>
      <td>2867.988073</td>
      <td>1758.544225</td>
      <td>0.939621</td>
    </tr>
    <tr>
      <th>8</th>
      <td>PH3</td>
      <td>-87.000</td>
      <td>34.0</td>
      <td>0.573970</td>
      <td>-87.000</td>
      <td>34.0</td>
      <td>0.573970</td>
      <td>-0.0464</td>
      <td>-24.935</td>
      <td>0.071538</td>
      <td>0.002153</td>
      <td>621.754225</td>
      <td>0.005118</td>
    </tr>
    <tr>
      <th>9</th>
      <td>AsH3</td>
      <td>-55.000</td>
      <td>77.9</td>
      <td>0.217000</td>
      <td>-55.000</td>
      <td>77.9</td>
      <td>0.217000</td>
      <td>31.9536</td>
      <td>18.965</td>
      <td>-0.285432</td>
      <td>1021.032553</td>
      <td>359.671225</td>
      <td>0.081471</td>
    </tr>
    <tr>
      <th>10</th>
      <td>SbH3</td>
      <td>-17.100</td>
      <td>124.8</td>
      <td>0.116000</td>
      <td>-17.100</td>
      <td>124.8</td>
      <td>0.116000</td>
      <td>69.8536</td>
      <td>65.865</td>
      <td>-0.386432</td>
      <td>4879.525433</td>
      <td>4338.198225</td>
      <td>0.149329</td>
    </tr>
    <tr>
      <th>11</th>
      <td>CH4</td>
      <td>-161.490</td>
      <td>16.0</td>
      <td>0.000000</td>
      <td>-161.490</td>
      <td>16.0</td>
      <td>0.000000</td>
      <td>-74.5364</td>
      <td>-42.935</td>
      <td>-0.502432</td>
      <td>5555.674925</td>
      <td>1843.414225</td>
      <td>0.252438</td>
    </tr>
    <tr>
      <th>12</th>
      <td>SiH4</td>
      <td>-111.800</td>
      <td>32.1</td>
      <td>0.000000</td>
      <td>-111.800</td>
      <td>32.1</td>
      <td>0.000000</td>
      <td>-24.8464</td>
      <td>-26.835</td>
      <td>-0.502432</td>
      <td>617.343593</td>
      <td>720.117225</td>
      <td>0.252438</td>
    </tr>
    <tr>
      <th>13</th>
      <td>GeH4</td>
      <td>-90.000</td>
      <td>76.6</td>
      <td>0.000000</td>
      <td>-90.000</td>
      <td>76.6</td>
      <td>0.000000</td>
      <td>-3.0464</td>
      <td>17.665</td>
      <td>-0.502432</td>
      <td>9.280553</td>
      <td>312.052225</td>
      <td>0.252438</td>
    </tr>
    <tr>
      <th>14</th>
      <td>SnH4</td>
      <td>-52.000</td>
      <td>122.7</td>
      <td>0.000000</td>
      <td>-52.000</td>
      <td>122.7</td>
      <td>0.000000</td>
      <td>34.9536</td>
      <td>63.765</td>
      <td>-0.502432</td>
      <td>1221.754153</td>
      <td>4065.975225</td>
      <td>0.252438</td>
    </tr>
    <tr>
      <th>15</th>
      <td>He</td>
      <td>-268.934</td>
      <td>4.0</td>
      <td>0.000000</td>
      <td>-268.934</td>
      <td>4.0</td>
      <td>0.000000</td>
      <td>-181.9804</td>
      <td>-54.935</td>
      <td>-0.502432</td>
      <td>33116.865984</td>
      <td>3017.854225</td>
      <td>0.252438</td>
    </tr>
    <tr>
      <th>16</th>
      <td>Ne</td>
      <td>-246.048</td>
      <td>20.2</td>
      <td>0.000000</td>
      <td>-246.048</td>
      <td>20.2</td>
      <td>0.000000</td>
      <td>-159.0944</td>
      <td>-38.735</td>
      <td>-0.502432</td>
      <td>25311.028111</td>
      <td>1500.400225</td>
      <td>0.252438</td>
    </tr>
    <tr>
      <th>17</th>
      <td>Ar</td>
      <td>-185.700</td>
      <td>39.9</td>
      <td>0.000000</td>
      <td>-185.700</td>
      <td>39.9</td>
      <td>0.000000</td>
      <td>-98.7464</td>
      <td>-19.035</td>
      <td>-0.502432</td>
      <td>9750.851513</td>
      <td>362.331225</td>
      <td>0.252438</td>
    </tr>
    <tr>
      <th>18</th>
      <td>Kr</td>
      <td>-152.300</td>
      <td>83.8</td>
      <td>0.000000</td>
      <td>-152.300</td>
      <td>83.8</td>
      <td>0.000000</td>
      <td>-65.3464</td>
      <td>24.865</td>
      <td>-0.502432</td>
      <td>4270.151993</td>
      <td>618.268225</td>
      <td>0.252438</td>
    </tr>
    <tr>
      <th>19</th>
      <td>Xe</td>
      <td>-108.100</td>
      <td>131.3</td>
      <td>0.000000</td>
      <td>-108.100</td>
      <td>131.3</td>
      <td>0.000000</td>
      <td>-21.1464</td>
      <td>72.365</td>
      <td>-0.502432</td>
      <td>447.170233</td>
      <td>5236.693225</td>
      <td>0.252438</td>
    </tr>
  </tbody>
</table>
</div>



<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>y</th>
      <th>x1</th>
      <th>x2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>mean</th>
      <td>-86.9536</td>
      <td>58.935</td>
      <td>0.502432</td>
    </tr>
  </tbody>
</table>
</div>



```python
variance_y = mean(excel['(y-mean(y))**2'])
variance_x1 = mean(excel['(x1-mean(x1))**2'])
variance_x2 = mean(excel['(x2-mean(x2))**2'])
sd_y = math.sqrt(variance_y)
sd_x1 = math.sqrt(variance_x1)
sd_x2 = math.sqrt(variance_x2)
display(excel, pd.DataFrame([[mean_y, mean_x1, mean_x2], 
                             [variance_y, variance_x1, variance_x2], 
                             [sd_y, sd_x1, sd_x2]], 
                            columns=['y','x1', 'x2'], index=['mean', 'variance', 'sd']))
```


<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>molecule</th>
      <th>boiling point</th>
      <th>molecular weight</th>
      <th>dipole monent</th>
      <th>y</th>
      <th>x1</th>
      <th>x2</th>
      <th>y-mean(y)</th>
      <th>x1-mean(x1)</th>
      <th>x2-mean(x2)</th>
      <th>(y-mean(y))**2</th>
      <th>(x1-mean(x1))**2</th>
      <th>(x2-mean(x2))**2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>HF</td>
      <td>19.500</td>
      <td>20.0</td>
      <td>1.826567</td>
      <td>19.500</td>
      <td>20.0</td>
      <td>1.826567</td>
      <td>106.4536</td>
      <td>-38.935</td>
      <td>1.324135</td>
      <td>11332.368953</td>
      <td>1515.934225</td>
      <td>1.753334</td>
    </tr>
    <tr>
      <th>1</th>
      <td>HCl</td>
      <td>-84.900</td>
      <td>36.5</td>
      <td>1.108600</td>
      <td>-84.900</td>
      <td>36.5</td>
      <td>1.108600</td>
      <td>2.0536</td>
      <td>-22.435</td>
      <td>0.606168</td>
      <td>4.217273</td>
      <td>503.329225</td>
      <td>0.367440</td>
    </tr>
    <tr>
      <th>2</th>
      <td>HBr</td>
      <td>-67.000</td>
      <td>80.9</td>
      <td>0.827100</td>
      <td>-67.000</td>
      <td>80.9</td>
      <td>0.827100</td>
      <td>19.9536</td>
      <td>21.965</td>
      <td>0.324668</td>
      <td>398.146153</td>
      <td>482.461225</td>
      <td>0.105410</td>
    </tr>
    <tr>
      <th>3</th>
      <td>HI</td>
      <td>-35.100</td>
      <td>127.9</td>
      <td>0.447700</td>
      <td>-35.100</td>
      <td>127.9</td>
      <td>0.447700</td>
      <td>51.8536</td>
      <td>68.965</td>
      <td>-0.054732</td>
      <td>2688.795833</td>
      <td>4756.171225</td>
      <td>0.002996</td>
    </tr>
    <tr>
      <th>4</th>
      <td>H2O</td>
      <td>100.000</td>
      <td>18.0</td>
      <td>1.854600</td>
      <td>100.000</td>
      <td>18.0</td>
      <td>1.854600</td>
      <td>186.9536</td>
      <td>-40.935</td>
      <td>1.352168</td>
      <td>34951.648553</td>
      <td>1675.674225</td>
      <td>1.828359</td>
    </tr>
    <tr>
      <th>5</th>
      <td>H2S</td>
      <td>-60.700</td>
      <td>34.1</td>
      <td>0.978325</td>
      <td>-60.700</td>
      <td>34.1</td>
      <td>0.978325</td>
      <td>26.2536</td>
      <td>-24.835</td>
      <td>0.475893</td>
      <td>689.251513</td>
      <td>616.777225</td>
      <td>0.226474</td>
    </tr>
    <tr>
      <th>6</th>
      <td>H2Se</td>
      <td>-42.000</td>
      <td>81.0</td>
      <td>0.627000</td>
      <td>-42.000</td>
      <td>81.0</td>
      <td>0.627000</td>
      <td>44.9536</td>
      <td>22.065</td>
      <td>0.124568</td>
      <td>2020.826153</td>
      <td>486.864225</td>
      <td>0.015517</td>
    </tr>
    <tr>
      <th>7</th>
      <td>NH3</td>
      <td>-33.400</td>
      <td>17.0</td>
      <td>1.471772</td>
      <td>-33.400</td>
      <td>17.0</td>
      <td>1.471772</td>
      <td>53.5536</td>
      <td>-41.935</td>
      <td>0.969340</td>
      <td>2867.988073</td>
      <td>1758.544225</td>
      <td>0.939621</td>
    </tr>
    <tr>
      <th>8</th>
      <td>PH3</td>
      <td>-87.000</td>
      <td>34.0</td>
      <td>0.573970</td>
      <td>-87.000</td>
      <td>34.0</td>
      <td>0.573970</td>
      <td>-0.0464</td>
      <td>-24.935</td>
      <td>0.071538</td>
      <td>0.002153</td>
      <td>621.754225</td>
      <td>0.005118</td>
    </tr>
    <tr>
      <th>9</th>
      <td>AsH3</td>
      <td>-55.000</td>
      <td>77.9</td>
      <td>0.217000</td>
      <td>-55.000</td>
      <td>77.9</td>
      <td>0.217000</td>
      <td>31.9536</td>
      <td>18.965</td>
      <td>-0.285432</td>
      <td>1021.032553</td>
      <td>359.671225</td>
      <td>0.081471</td>
    </tr>
    <tr>
      <th>10</th>
      <td>SbH3</td>
      <td>-17.100</td>
      <td>124.8</td>
      <td>0.116000</td>
      <td>-17.100</td>
      <td>124.8</td>
      <td>0.116000</td>
      <td>69.8536</td>
      <td>65.865</td>
      <td>-0.386432</td>
      <td>4879.525433</td>
      <td>4338.198225</td>
      <td>0.149329</td>
    </tr>
    <tr>
      <th>11</th>
      <td>CH4</td>
      <td>-161.490</td>
      <td>16.0</td>
      <td>0.000000</td>
      <td>-161.490</td>
      <td>16.0</td>
      <td>0.000000</td>
      <td>-74.5364</td>
      <td>-42.935</td>
      <td>-0.502432</td>
      <td>5555.674925</td>
      <td>1843.414225</td>
      <td>0.252438</td>
    </tr>
    <tr>
      <th>12</th>
      <td>SiH4</td>
      <td>-111.800</td>
      <td>32.1</td>
      <td>0.000000</td>
      <td>-111.800</td>
      <td>32.1</td>
      <td>0.000000</td>
      <td>-24.8464</td>
      <td>-26.835</td>
      <td>-0.502432</td>
      <td>617.343593</td>
      <td>720.117225</td>
      <td>0.252438</td>
    </tr>
    <tr>
      <th>13</th>
      <td>GeH4</td>
      <td>-90.000</td>
      <td>76.6</td>
      <td>0.000000</td>
      <td>-90.000</td>
      <td>76.6</td>
      <td>0.000000</td>
      <td>-3.0464</td>
      <td>17.665</td>
      <td>-0.502432</td>
      <td>9.280553</td>
      <td>312.052225</td>
      <td>0.252438</td>
    </tr>
    <tr>
      <th>14</th>
      <td>SnH4</td>
      <td>-52.000</td>
      <td>122.7</td>
      <td>0.000000</td>
      <td>-52.000</td>
      <td>122.7</td>
      <td>0.000000</td>
      <td>34.9536</td>
      <td>63.765</td>
      <td>-0.502432</td>
      <td>1221.754153</td>
      <td>4065.975225</td>
      <td>0.252438</td>
    </tr>
    <tr>
      <th>15</th>
      <td>He</td>
      <td>-268.934</td>
      <td>4.0</td>
      <td>0.000000</td>
      <td>-268.934</td>
      <td>4.0</td>
      <td>0.000000</td>
      <td>-181.9804</td>
      <td>-54.935</td>
      <td>-0.502432</td>
      <td>33116.865984</td>
      <td>3017.854225</td>
      <td>0.252438</td>
    </tr>
    <tr>
      <th>16</th>
      <td>Ne</td>
      <td>-246.048</td>
      <td>20.2</td>
      <td>0.000000</td>
      <td>-246.048</td>
      <td>20.2</td>
      <td>0.000000</td>
      <td>-159.0944</td>
      <td>-38.735</td>
      <td>-0.502432</td>
      <td>25311.028111</td>
      <td>1500.400225</td>
      <td>0.252438</td>
    </tr>
    <tr>
      <th>17</th>
      <td>Ar</td>
      <td>-185.700</td>
      <td>39.9</td>
      <td>0.000000</td>
      <td>-185.700</td>
      <td>39.9</td>
      <td>0.000000</td>
      <td>-98.7464</td>
      <td>-19.035</td>
      <td>-0.502432</td>
      <td>9750.851513</td>
      <td>362.331225</td>
      <td>0.252438</td>
    </tr>
    <tr>
      <th>18</th>
      <td>Kr</td>
      <td>-152.300</td>
      <td>83.8</td>
      <td>0.000000</td>
      <td>-152.300</td>
      <td>83.8</td>
      <td>0.000000</td>
      <td>-65.3464</td>
      <td>24.865</td>
      <td>-0.502432</td>
      <td>4270.151993</td>
      <td>618.268225</td>
      <td>0.252438</td>
    </tr>
    <tr>
      <th>19</th>
      <td>Xe</td>
      <td>-108.100</td>
      <td>131.3</td>
      <td>0.000000</td>
      <td>-108.100</td>
      <td>131.3</td>
      <td>0.000000</td>
      <td>-21.1464</td>
      <td>72.365</td>
      <td>-0.502432</td>
      <td>447.170233</td>
      <td>5236.693225</td>
      <td>0.252438</td>
    </tr>
  </tbody>
</table>
</div>



<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>y</th>
      <th>x1</th>
      <th>x2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>mean</th>
      <td>-86.953600</td>
      <td>58.935000</td>
      <td>0.502432</td>
    </tr>
    <tr>
      <th>variance</th>
      <td>7057.696185</td>
      <td>1739.624275</td>
      <td>0.387350</td>
    </tr>
    <tr>
      <th>sd</th>
      <td>84.010096</td>
      <td>41.708803</td>
      <td>0.622375</td>
    </tr>
  </tbody>
</table>
</div>



```python
excel['(x1-mean(x1)) * (x2-mean(x2))'] = excel['x1-mean(x1)'] * excel['x2-mean(x2)']
excel['(y-mean(y)) * (x1-mean(x1))'] = excel['y-mean(y)'] * excel['x1-mean(x1)']
excel['(y-mean(y)) * (x2-mean(x2))'] = excel['y-mean(y)'] * excel['x2-mean(x2)']
display(excel, pd.DataFrame([[mean_y, mean_x1, mean_x2], 
                             [variance_y, variance_x1, variance_x2], 
                             [sd_y, sd_x1, sd_x2]], 
                            columns=['y','x1', 'x2'], index=['mean', 'variance', 'sd']))
```


<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>molecule</th>
      <th>boiling point</th>
      <th>molecular weight</th>
      <th>dipole monent</th>
      <th>y</th>
      <th>x1</th>
      <th>x2</th>
      <th>y-mean(y)</th>
      <th>x1-mean(x1)</th>
      <th>x2-mean(x2)</th>
      <th>(y-mean(y))**2</th>
      <th>(x1-mean(x1))**2</th>
      <th>(x2-mean(x2))**2</th>
      <th>(x1-mean(x1)) * (x2-mean(x2))</th>
      <th>(y-mean(y)) * (x1-mean(x1))</th>
      <th>(y-mean(y)) * (x2-mean(x2))</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>HF</td>
      <td>19.500</td>
      <td>20.0</td>
      <td>1.826567</td>
      <td>19.500</td>
      <td>20.0</td>
      <td>1.826567</td>
      <td>106.4536</td>
      <td>-38.935</td>
      <td>1.324135</td>
      <td>11332.368953</td>
      <td>1515.934225</td>
      <td>1.753334</td>
      <td>-51.555208</td>
      <td>-4144.770916</td>
      <td>140.958970</td>
    </tr>
    <tr>
      <th>1</th>
      <td>HCl</td>
      <td>-84.900</td>
      <td>36.5</td>
      <td>1.108600</td>
      <td>-84.900</td>
      <td>36.5</td>
      <td>1.108600</td>
      <td>2.0536</td>
      <td>-22.435</td>
      <td>0.606168</td>
      <td>4.217273</td>
      <td>503.329225</td>
      <td>0.367440</td>
      <td>-13.599386</td>
      <td>-46.072516</td>
      <td>1.244827</td>
    </tr>
    <tr>
      <th>2</th>
      <td>HBr</td>
      <td>-67.000</td>
      <td>80.9</td>
      <td>0.827100</td>
      <td>-67.000</td>
      <td>80.9</td>
      <td>0.827100</td>
      <td>19.9536</td>
      <td>21.965</td>
      <td>0.324668</td>
      <td>398.146153</td>
      <td>482.461225</td>
      <td>0.105410</td>
      <td>7.131339</td>
      <td>438.280824</td>
      <td>6.478301</td>
    </tr>
    <tr>
      <th>3</th>
      <td>HI</td>
      <td>-35.100</td>
      <td>127.9</td>
      <td>0.447700</td>
      <td>-35.100</td>
      <td>127.9</td>
      <td>0.447700</td>
      <td>51.8536</td>
      <td>68.965</td>
      <td>-0.054732</td>
      <td>2688.795833</td>
      <td>4756.171225</td>
      <td>0.002996</td>
      <td>-3.774572</td>
      <td>3576.083524</td>
      <td>-2.838036</td>
    </tr>
    <tr>
      <th>4</th>
      <td>H2O</td>
      <td>100.000</td>
      <td>18.0</td>
      <td>1.854600</td>
      <td>100.000</td>
      <td>18.0</td>
      <td>1.854600</td>
      <td>186.9536</td>
      <td>-40.935</td>
      <td>1.352168</td>
      <td>34951.648553</td>
      <td>1675.674225</td>
      <td>1.828359</td>
      <td>-55.351009</td>
      <td>-7652.945616</td>
      <td>252.792731</td>
    </tr>
    <tr>
      <th>5</th>
      <td>H2S</td>
      <td>-60.700</td>
      <td>34.1</td>
      <td>0.978325</td>
      <td>-60.700</td>
      <td>34.1</td>
      <td>0.978325</td>
      <td>26.2536</td>
      <td>-24.835</td>
      <td>0.475893</td>
      <td>689.251513</td>
      <td>616.777225</td>
      <td>0.226474</td>
      <td>-11.818810</td>
      <td>-652.008156</td>
      <td>12.493912</td>
    </tr>
    <tr>
      <th>6</th>
      <td>H2Se</td>
      <td>-42.000</td>
      <td>81.0</td>
      <td>0.627000</td>
      <td>-42.000</td>
      <td>81.0</td>
      <td>0.627000</td>
      <td>44.9536</td>
      <td>22.065</td>
      <td>0.124568</td>
      <td>2020.826153</td>
      <td>486.864225</td>
      <td>0.015517</td>
      <td>2.748600</td>
      <td>991.901184</td>
      <td>5.599794</td>
    </tr>
    <tr>
      <th>7</th>
      <td>NH3</td>
      <td>-33.400</td>
      <td>17.0</td>
      <td>1.471772</td>
      <td>-33.400</td>
      <td>17.0</td>
      <td>1.471772</td>
      <td>53.5536</td>
      <td>-41.935</td>
      <td>0.969340</td>
      <td>2867.988073</td>
      <td>1758.544225</td>
      <td>0.939621</td>
      <td>-40.649285</td>
      <td>-2245.770216</td>
      <td>51.911663</td>
    </tr>
    <tr>
      <th>8</th>
      <td>PH3</td>
      <td>-87.000</td>
      <td>34.0</td>
      <td>0.573970</td>
      <td>-87.000</td>
      <td>34.0</td>
      <td>0.573970</td>
      <td>-0.0464</td>
      <td>-24.935</td>
      <td>0.071538</td>
      <td>0.002153</td>
      <td>621.754225</td>
      <td>0.005118</td>
      <td>-1.783808</td>
      <td>1.156984</td>
      <td>-0.003319</td>
    </tr>
    <tr>
      <th>9</th>
      <td>AsH3</td>
      <td>-55.000</td>
      <td>77.9</td>
      <td>0.217000</td>
      <td>-55.000</td>
      <td>77.9</td>
      <td>0.217000</td>
      <td>31.9536</td>
      <td>18.965</td>
      <td>-0.285432</td>
      <td>1021.032553</td>
      <td>359.671225</td>
      <td>0.081471</td>
      <td>-5.413212</td>
      <td>606.000024</td>
      <td>-9.120570</td>
    </tr>
    <tr>
      <th>10</th>
      <td>SbH3</td>
      <td>-17.100</td>
      <td>124.8</td>
      <td>0.116000</td>
      <td>-17.100</td>
      <td>124.8</td>
      <td>0.116000</td>
      <td>69.8536</td>
      <td>65.865</td>
      <td>-0.386432</td>
      <td>4879.525433</td>
      <td>4338.198225</td>
      <td>0.149329</td>
      <td>-25.452324</td>
      <td>4600.907364</td>
      <td>-26.993645</td>
    </tr>
    <tr>
      <th>11</th>
      <td>CH4</td>
      <td>-161.490</td>
      <td>16.0</td>
      <td>0.000000</td>
      <td>-161.490</td>
      <td>16.0</td>
      <td>0.000000</td>
      <td>-74.5364</td>
      <td>-42.935</td>
      <td>-0.502432</td>
      <td>5555.674925</td>
      <td>1843.414225</td>
      <td>0.252438</td>
      <td>21.571905</td>
      <td>3200.220334</td>
      <td>37.449450</td>
    </tr>
    <tr>
      <th>12</th>
      <td>SiH4</td>
      <td>-111.800</td>
      <td>32.1</td>
      <td>0.000000</td>
      <td>-111.800</td>
      <td>32.1</td>
      <td>0.000000</td>
      <td>-24.8464</td>
      <td>-26.835</td>
      <td>-0.502432</td>
      <td>617.343593</td>
      <td>720.117225</td>
      <td>0.252438</td>
      <td>13.482755</td>
      <td>666.753144</td>
      <td>12.483619</td>
    </tr>
    <tr>
      <th>13</th>
      <td>GeH4</td>
      <td>-90.000</td>
      <td>76.6</td>
      <td>0.000000</td>
      <td>-90.000</td>
      <td>76.6</td>
      <td>0.000000</td>
      <td>-3.0464</td>
      <td>17.665</td>
      <td>-0.502432</td>
      <td>9.280553</td>
      <td>312.052225</td>
      <td>0.252438</td>
      <td>-8.875456</td>
      <td>-53.814656</td>
      <td>1.530608</td>
    </tr>
    <tr>
      <th>14</th>
      <td>SnH4</td>
      <td>-52.000</td>
      <td>122.7</td>
      <td>0.000000</td>
      <td>-52.000</td>
      <td>122.7</td>
      <td>0.000000</td>
      <td>34.9536</td>
      <td>63.765</td>
      <td>-0.502432</td>
      <td>1221.754153</td>
      <td>4065.975225</td>
      <td>0.252438</td>
      <td>-32.037557</td>
      <td>2228.816304</td>
      <td>-17.561797</td>
    </tr>
    <tr>
      <th>15</th>
      <td>He</td>
      <td>-268.934</td>
      <td>4.0</td>
      <td>0.000000</td>
      <td>-268.934</td>
      <td>4.0</td>
      <td>0.000000</td>
      <td>-181.9804</td>
      <td>-54.935</td>
      <td>-0.502432</td>
      <td>33116.865984</td>
      <td>3017.854225</td>
      <td>0.252438</td>
      <td>27.601085</td>
      <td>9997.093274</td>
      <td>91.432722</td>
    </tr>
    <tr>
      <th>16</th>
      <td>Ne</td>
      <td>-246.048</td>
      <td>20.2</td>
      <td>0.000000</td>
      <td>-246.048</td>
      <td>20.2</td>
      <td>0.000000</td>
      <td>-159.0944</td>
      <td>-38.735</td>
      <td>-0.502432</td>
      <td>25311.028111</td>
      <td>1500.400225</td>
      <td>0.252438</td>
      <td>19.461692</td>
      <td>6162.521584</td>
      <td>79.934070</td>
    </tr>
    <tr>
      <th>17</th>
      <td>Ar</td>
      <td>-185.700</td>
      <td>39.9</td>
      <td>0.000000</td>
      <td>-185.700</td>
      <td>39.9</td>
      <td>0.000000</td>
      <td>-98.7464</td>
      <td>-19.035</td>
      <td>-0.502432</td>
      <td>9750.851513</td>
      <td>362.331225</td>
      <td>0.252438</td>
      <td>9.563787</td>
      <td>1879.637724</td>
      <td>49.613322</td>
    </tr>
    <tr>
      <th>18</th>
      <td>Kr</td>
      <td>-152.300</td>
      <td>83.8</td>
      <td>0.000000</td>
      <td>-152.300</td>
      <td>83.8</td>
      <td>0.000000</td>
      <td>-65.3464</td>
      <td>24.865</td>
      <td>-0.502432</td>
      <td>4270.151993</td>
      <td>618.268225</td>
      <td>0.252438</td>
      <td>-12.492964</td>
      <td>-1624.838236</td>
      <td>32.832103</td>
    </tr>
    <tr>
      <th>19</th>
      <td>Xe</td>
      <td>-108.100</td>
      <td>131.3</td>
      <td>0.000000</td>
      <td>-108.100</td>
      <td>131.3</td>
      <td>0.000000</td>
      <td>-21.1464</td>
      <td>72.365</td>
      <td>-0.502432</td>
      <td>447.170233</td>
      <td>5236.693225</td>
      <td>0.252438</td>
      <td>-36.358470</td>
      <td>-1530.259236</td>
      <td>10.624622</td>
    </tr>
  </tbody>
</table>
</div>



<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>y</th>
      <th>x1</th>
      <th>x2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>mean</th>
      <td>-86.953600</td>
      <td>58.935000</td>
      <td>0.502432</td>
    </tr>
    <tr>
      <th>variance</th>
      <td>7057.696185</td>
      <td>1739.624275</td>
      <td>0.387350</td>
    </tr>
    <tr>
      <th>sd</th>
      <td>84.010096</td>
      <td>41.708803</td>
      <td>0.622375</td>
    </tr>
  </tbody>
</table>
</div>



```python
covar_x1x2 = mean(excel['(x1-mean(x1)) * (x2-mean(x2))'])
covar_x1y = mean(excel['(y-mean(y)) * (x1-mean(x1))'])
covar_x2y = mean(excel['(y-mean(y)) * (x2-mean(x2))'])

corr_x1x2 = covar_x1x2 / (sd_x1 * sd_x2)
corr_x1y = covar_x1y / (sd_x1 * sd_y)
corr_x2y = covar_x2y / (sd_x2 * sd_y)
display(excel, pd.DataFrame([[mean_y, mean_x1, mean_x2], 
                             [variance_y, variance_x1, variance_x2], 
                             [sd_y, sd_x1, sd_x2]], 
                            columns=['y','x1', 'x2'], index=['mean', 'variance', 'sd']),
       pd.DataFrame([[covar_x1x2, covar_x1y, covar_x2y], [corr_x1x2, corr_x1y, corr_x2y]], 
                    index=['covariance', 'correlation'], columns=['x1,x2','x1,y', 'x2,y']))
```


<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>molecule</th>
      <th>boiling point</th>
      <th>molecular weight</th>
      <th>dipole monent</th>
      <th>y</th>
      <th>x1</th>
      <th>x2</th>
      <th>y-mean(y)</th>
      <th>x1-mean(x1)</th>
      <th>x2-mean(x2)</th>
      <th>(y-mean(y))**2</th>
      <th>(x1-mean(x1))**2</th>
      <th>(x2-mean(x2))**2</th>
      <th>(x1-mean(x1)) * (x2-mean(x2))</th>
      <th>(y-mean(y)) * (x1-mean(x1))</th>
      <th>(y-mean(y)) * (x2-mean(x2))</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>HF</td>
      <td>19.500</td>
      <td>20.0</td>
      <td>1.826567</td>
      <td>19.500</td>
      <td>20.0</td>
      <td>1.826567</td>
      <td>106.4536</td>
      <td>-38.935</td>
      <td>1.324135</td>
      <td>11332.368953</td>
      <td>1515.934225</td>
      <td>1.753334</td>
      <td>-51.555208</td>
      <td>-4144.770916</td>
      <td>140.958970</td>
    </tr>
    <tr>
      <th>1</th>
      <td>HCl</td>
      <td>-84.900</td>
      <td>36.5</td>
      <td>1.108600</td>
      <td>-84.900</td>
      <td>36.5</td>
      <td>1.108600</td>
      <td>2.0536</td>
      <td>-22.435</td>
      <td>0.606168</td>
      <td>4.217273</td>
      <td>503.329225</td>
      <td>0.367440</td>
      <td>-13.599386</td>
      <td>-46.072516</td>
      <td>1.244827</td>
    </tr>
    <tr>
      <th>2</th>
      <td>HBr</td>
      <td>-67.000</td>
      <td>80.9</td>
      <td>0.827100</td>
      <td>-67.000</td>
      <td>80.9</td>
      <td>0.827100</td>
      <td>19.9536</td>
      <td>21.965</td>
      <td>0.324668</td>
      <td>398.146153</td>
      <td>482.461225</td>
      <td>0.105410</td>
      <td>7.131339</td>
      <td>438.280824</td>
      <td>6.478301</td>
    </tr>
    <tr>
      <th>3</th>
      <td>HI</td>
      <td>-35.100</td>
      <td>127.9</td>
      <td>0.447700</td>
      <td>-35.100</td>
      <td>127.9</td>
      <td>0.447700</td>
      <td>51.8536</td>
      <td>68.965</td>
      <td>-0.054732</td>
      <td>2688.795833</td>
      <td>4756.171225</td>
      <td>0.002996</td>
      <td>-3.774572</td>
      <td>3576.083524</td>
      <td>-2.838036</td>
    </tr>
    <tr>
      <th>4</th>
      <td>H2O</td>
      <td>100.000</td>
      <td>18.0</td>
      <td>1.854600</td>
      <td>100.000</td>
      <td>18.0</td>
      <td>1.854600</td>
      <td>186.9536</td>
      <td>-40.935</td>
      <td>1.352168</td>
      <td>34951.648553</td>
      <td>1675.674225</td>
      <td>1.828359</td>
      <td>-55.351009</td>
      <td>-7652.945616</td>
      <td>252.792731</td>
    </tr>
    <tr>
      <th>5</th>
      <td>H2S</td>
      <td>-60.700</td>
      <td>34.1</td>
      <td>0.978325</td>
      <td>-60.700</td>
      <td>34.1</td>
      <td>0.978325</td>
      <td>26.2536</td>
      <td>-24.835</td>
      <td>0.475893</td>
      <td>689.251513</td>
      <td>616.777225</td>
      <td>0.226474</td>
      <td>-11.818810</td>
      <td>-652.008156</td>
      <td>12.493912</td>
    </tr>
    <tr>
      <th>6</th>
      <td>H2Se</td>
      <td>-42.000</td>
      <td>81.0</td>
      <td>0.627000</td>
      <td>-42.000</td>
      <td>81.0</td>
      <td>0.627000</td>
      <td>44.9536</td>
      <td>22.065</td>
      <td>0.124568</td>
      <td>2020.826153</td>
      <td>486.864225</td>
      <td>0.015517</td>
      <td>2.748600</td>
      <td>991.901184</td>
      <td>5.599794</td>
    </tr>
    <tr>
      <th>7</th>
      <td>NH3</td>
      <td>-33.400</td>
      <td>17.0</td>
      <td>1.471772</td>
      <td>-33.400</td>
      <td>17.0</td>
      <td>1.471772</td>
      <td>53.5536</td>
      <td>-41.935</td>
      <td>0.969340</td>
      <td>2867.988073</td>
      <td>1758.544225</td>
      <td>0.939621</td>
      <td>-40.649285</td>
      <td>-2245.770216</td>
      <td>51.911663</td>
    </tr>
    <tr>
      <th>8</th>
      <td>PH3</td>
      <td>-87.000</td>
      <td>34.0</td>
      <td>0.573970</td>
      <td>-87.000</td>
      <td>34.0</td>
      <td>0.573970</td>
      <td>-0.0464</td>
      <td>-24.935</td>
      <td>0.071538</td>
      <td>0.002153</td>
      <td>621.754225</td>
      <td>0.005118</td>
      <td>-1.783808</td>
      <td>1.156984</td>
      <td>-0.003319</td>
    </tr>
    <tr>
      <th>9</th>
      <td>AsH3</td>
      <td>-55.000</td>
      <td>77.9</td>
      <td>0.217000</td>
      <td>-55.000</td>
      <td>77.9</td>
      <td>0.217000</td>
      <td>31.9536</td>
      <td>18.965</td>
      <td>-0.285432</td>
      <td>1021.032553</td>
      <td>359.671225</td>
      <td>0.081471</td>
      <td>-5.413212</td>
      <td>606.000024</td>
      <td>-9.120570</td>
    </tr>
    <tr>
      <th>10</th>
      <td>SbH3</td>
      <td>-17.100</td>
      <td>124.8</td>
      <td>0.116000</td>
      <td>-17.100</td>
      <td>124.8</td>
      <td>0.116000</td>
      <td>69.8536</td>
      <td>65.865</td>
      <td>-0.386432</td>
      <td>4879.525433</td>
      <td>4338.198225</td>
      <td>0.149329</td>
      <td>-25.452324</td>
      <td>4600.907364</td>
      <td>-26.993645</td>
    </tr>
    <tr>
      <th>11</th>
      <td>CH4</td>
      <td>-161.490</td>
      <td>16.0</td>
      <td>0.000000</td>
      <td>-161.490</td>
      <td>16.0</td>
      <td>0.000000</td>
      <td>-74.5364</td>
      <td>-42.935</td>
      <td>-0.502432</td>
      <td>5555.674925</td>
      <td>1843.414225</td>
      <td>0.252438</td>
      <td>21.571905</td>
      <td>3200.220334</td>
      <td>37.449450</td>
    </tr>
    <tr>
      <th>12</th>
      <td>SiH4</td>
      <td>-111.800</td>
      <td>32.1</td>
      <td>0.000000</td>
      <td>-111.800</td>
      <td>32.1</td>
      <td>0.000000</td>
      <td>-24.8464</td>
      <td>-26.835</td>
      <td>-0.502432</td>
      <td>617.343593</td>
      <td>720.117225</td>
      <td>0.252438</td>
      <td>13.482755</td>
      <td>666.753144</td>
      <td>12.483619</td>
    </tr>
    <tr>
      <th>13</th>
      <td>GeH4</td>
      <td>-90.000</td>
      <td>76.6</td>
      <td>0.000000</td>
      <td>-90.000</td>
      <td>76.6</td>
      <td>0.000000</td>
      <td>-3.0464</td>
      <td>17.665</td>
      <td>-0.502432</td>
      <td>9.280553</td>
      <td>312.052225</td>
      <td>0.252438</td>
      <td>-8.875456</td>
      <td>-53.814656</td>
      <td>1.530608</td>
    </tr>
    <tr>
      <th>14</th>
      <td>SnH4</td>
      <td>-52.000</td>
      <td>122.7</td>
      <td>0.000000</td>
      <td>-52.000</td>
      <td>122.7</td>
      <td>0.000000</td>
      <td>34.9536</td>
      <td>63.765</td>
      <td>-0.502432</td>
      <td>1221.754153</td>
      <td>4065.975225</td>
      <td>0.252438</td>
      <td>-32.037557</td>
      <td>2228.816304</td>
      <td>-17.561797</td>
    </tr>
    <tr>
      <th>15</th>
      <td>He</td>
      <td>-268.934</td>
      <td>4.0</td>
      <td>0.000000</td>
      <td>-268.934</td>
      <td>4.0</td>
      <td>0.000000</td>
      <td>-181.9804</td>
      <td>-54.935</td>
      <td>-0.502432</td>
      <td>33116.865984</td>
      <td>3017.854225</td>
      <td>0.252438</td>
      <td>27.601085</td>
      <td>9997.093274</td>
      <td>91.432722</td>
    </tr>
    <tr>
      <th>16</th>
      <td>Ne</td>
      <td>-246.048</td>
      <td>20.2</td>
      <td>0.000000</td>
      <td>-246.048</td>
      <td>20.2</td>
      <td>0.000000</td>
      <td>-159.0944</td>
      <td>-38.735</td>
      <td>-0.502432</td>
      <td>25311.028111</td>
      <td>1500.400225</td>
      <td>0.252438</td>
      <td>19.461692</td>
      <td>6162.521584</td>
      <td>79.934070</td>
    </tr>
    <tr>
      <th>17</th>
      <td>Ar</td>
      <td>-185.700</td>
      <td>39.9</td>
      <td>0.000000</td>
      <td>-185.700</td>
      <td>39.9</td>
      <td>0.000000</td>
      <td>-98.7464</td>
      <td>-19.035</td>
      <td>-0.502432</td>
      <td>9750.851513</td>
      <td>362.331225</td>
      <td>0.252438</td>
      <td>9.563787</td>
      <td>1879.637724</td>
      <td>49.613322</td>
    </tr>
    <tr>
      <th>18</th>
      <td>Kr</td>
      <td>-152.300</td>
      <td>83.8</td>
      <td>0.000000</td>
      <td>-152.300</td>
      <td>83.8</td>
      <td>0.000000</td>
      <td>-65.3464</td>
      <td>24.865</td>
      <td>-0.502432</td>
      <td>4270.151993</td>
      <td>618.268225</td>
      <td>0.252438</td>
      <td>-12.492964</td>
      <td>-1624.838236</td>
      <td>32.832103</td>
    </tr>
    <tr>
      <th>19</th>
      <td>Xe</td>
      <td>-108.100</td>
      <td>131.3</td>
      <td>0.000000</td>
      <td>-108.100</td>
      <td>131.3</td>
      <td>0.000000</td>
      <td>-21.1464</td>
      <td>72.365</td>
      <td>-0.502432</td>
      <td>447.170233</td>
      <td>5236.693225</td>
      <td>0.252438</td>
      <td>-36.358470</td>
      <td>-1530.259236</td>
      <td>10.624622</td>
    </tr>
  </tbody>
</table>
</div>



<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>y</th>
      <th>x1</th>
      <th>x2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>mean</th>
      <td>-86.953600</td>
      <td>58.935000</td>
      <td>0.502432</td>
    </tr>
    <tr>
      <th>variance</th>
      <td>7057.696185</td>
      <td>1739.624275</td>
      <td>0.387350</td>
    </tr>
    <tr>
      <th>sd</th>
      <td>84.010096</td>
      <td>41.708803</td>
      <td>0.622375</td>
    </tr>
  </tbody>
</table>
</div>



<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>x1,x2</th>
      <th>x1,y</th>
      <th>x2,y</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>covariance</th>
      <td>-9.880045</td>
      <td>819.944636</td>
      <td>36.543167</td>
    </tr>
    <tr>
      <th>correlation</th>
      <td>-0.380609</td>
      <td>0.234005</td>
      <td>0.698912</td>
    </tr>
  </tbody>
</table>
</div>



```python
w1 = (corr_x1y - corr_x2y * corr_x1x2) * sd_y / ((1 - corr_x1x2 ** 2) * sd_x1)
w2 = (corr_x2y - corr_x1y * corr_x1x2) * sd_y / ((1 - corr_x1x2 ** 2) * sd_x2)
t = mean_y - w1 * mean_x1 - w2 * mean_x2
display(excel, 
        pd.DataFrame([[mean_y, mean_x1, mean_x2], 
                      [variance_y, variance_x1, variance_x2], 
                      [sd_y, sd_x1, sd_x2]], 
                     columns=['y','x1', 'x2'], index=['mean', 'variance', 'sd']),
        pd.DataFrame([[covar_x1x2, covar_x1y, covar_x2y], [corr_x1x2, corr_x1y, corr_x2y]], 
                     index=['covariance', 'correlation'], columns=['x1,x2','x1,y', 'x2,y']),
        pd.DataFrame([[w1, w2, t]], columns=["w1", "w2", "t"], index=["y = f(x) = w1x1 + w2x2 + t"]))
```


<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>molecule</th>
      <th>boiling point</th>
      <th>molecular weight</th>
      <th>dipole monent</th>
      <th>y</th>
      <th>x1</th>
      <th>x2</th>
      <th>y-mean(y)</th>
      <th>x1-mean(x1)</th>
      <th>x2-mean(x2)</th>
      <th>(y-mean(y))**2</th>
      <th>(x1-mean(x1))**2</th>
      <th>(x2-mean(x2))**2</th>
      <th>(x1-mean(x1)) * (x2-mean(x2))</th>
      <th>(y-mean(y)) * (x1-mean(x1))</th>
      <th>(y-mean(y)) * (x2-mean(x2))</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>HF</td>
      <td>19.500</td>
      <td>20.0</td>
      <td>1.826567</td>
      <td>19.500</td>
      <td>20.0</td>
      <td>1.826567</td>
      <td>106.4536</td>
      <td>-38.935</td>
      <td>1.324135</td>
      <td>11332.368953</td>
      <td>1515.934225</td>
      <td>1.753334</td>
      <td>-51.555208</td>
      <td>-4144.770916</td>
      <td>140.958970</td>
    </tr>
    <tr>
      <th>1</th>
      <td>HCl</td>
      <td>-84.900</td>
      <td>36.5</td>
      <td>1.108600</td>
      <td>-84.900</td>
      <td>36.5</td>
      <td>1.108600</td>
      <td>2.0536</td>
      <td>-22.435</td>
      <td>0.606168</td>
      <td>4.217273</td>
      <td>503.329225</td>
      <td>0.367440</td>
      <td>-13.599386</td>
      <td>-46.072516</td>
      <td>1.244827</td>
    </tr>
    <tr>
      <th>2</th>
      <td>HBr</td>
      <td>-67.000</td>
      <td>80.9</td>
      <td>0.827100</td>
      <td>-67.000</td>
      <td>80.9</td>
      <td>0.827100</td>
      <td>19.9536</td>
      <td>21.965</td>
      <td>0.324668</td>
      <td>398.146153</td>
      <td>482.461225</td>
      <td>0.105410</td>
      <td>7.131339</td>
      <td>438.280824</td>
      <td>6.478301</td>
    </tr>
    <tr>
      <th>3</th>
      <td>HI</td>
      <td>-35.100</td>
      <td>127.9</td>
      <td>0.447700</td>
      <td>-35.100</td>
      <td>127.9</td>
      <td>0.447700</td>
      <td>51.8536</td>
      <td>68.965</td>
      <td>-0.054732</td>
      <td>2688.795833</td>
      <td>4756.171225</td>
      <td>0.002996</td>
      <td>-3.774572</td>
      <td>3576.083524</td>
      <td>-2.838036</td>
    </tr>
    <tr>
      <th>4</th>
      <td>H2O</td>
      <td>100.000</td>
      <td>18.0</td>
      <td>1.854600</td>
      <td>100.000</td>
      <td>18.0</td>
      <td>1.854600</td>
      <td>186.9536</td>
      <td>-40.935</td>
      <td>1.352168</td>
      <td>34951.648553</td>
      <td>1675.674225</td>
      <td>1.828359</td>
      <td>-55.351009</td>
      <td>-7652.945616</td>
      <td>252.792731</td>
    </tr>
    <tr>
      <th>5</th>
      <td>H2S</td>
      <td>-60.700</td>
      <td>34.1</td>
      <td>0.978325</td>
      <td>-60.700</td>
      <td>34.1</td>
      <td>0.978325</td>
      <td>26.2536</td>
      <td>-24.835</td>
      <td>0.475893</td>
      <td>689.251513</td>
      <td>616.777225</td>
      <td>0.226474</td>
      <td>-11.818810</td>
      <td>-652.008156</td>
      <td>12.493912</td>
    </tr>
    <tr>
      <th>6</th>
      <td>H2Se</td>
      <td>-42.000</td>
      <td>81.0</td>
      <td>0.627000</td>
      <td>-42.000</td>
      <td>81.0</td>
      <td>0.627000</td>
      <td>44.9536</td>
      <td>22.065</td>
      <td>0.124568</td>
      <td>2020.826153</td>
      <td>486.864225</td>
      <td>0.015517</td>
      <td>2.748600</td>
      <td>991.901184</td>
      <td>5.599794</td>
    </tr>
    <tr>
      <th>7</th>
      <td>NH3</td>
      <td>-33.400</td>
      <td>17.0</td>
      <td>1.471772</td>
      <td>-33.400</td>
      <td>17.0</td>
      <td>1.471772</td>
      <td>53.5536</td>
      <td>-41.935</td>
      <td>0.969340</td>
      <td>2867.988073</td>
      <td>1758.544225</td>
      <td>0.939621</td>
      <td>-40.649285</td>
      <td>-2245.770216</td>
      <td>51.911663</td>
    </tr>
    <tr>
      <th>8</th>
      <td>PH3</td>
      <td>-87.000</td>
      <td>34.0</td>
      <td>0.573970</td>
      <td>-87.000</td>
      <td>34.0</td>
      <td>0.573970</td>
      <td>-0.0464</td>
      <td>-24.935</td>
      <td>0.071538</td>
      <td>0.002153</td>
      <td>621.754225</td>
      <td>0.005118</td>
      <td>-1.783808</td>
      <td>1.156984</td>
      <td>-0.003319</td>
    </tr>
    <tr>
      <th>9</th>
      <td>AsH3</td>
      <td>-55.000</td>
      <td>77.9</td>
      <td>0.217000</td>
      <td>-55.000</td>
      <td>77.9</td>
      <td>0.217000</td>
      <td>31.9536</td>
      <td>18.965</td>
      <td>-0.285432</td>
      <td>1021.032553</td>
      <td>359.671225</td>
      <td>0.081471</td>
      <td>-5.413212</td>
      <td>606.000024</td>
      <td>-9.120570</td>
    </tr>
    <tr>
      <th>10</th>
      <td>SbH3</td>
      <td>-17.100</td>
      <td>124.8</td>
      <td>0.116000</td>
      <td>-17.100</td>
      <td>124.8</td>
      <td>0.116000</td>
      <td>69.8536</td>
      <td>65.865</td>
      <td>-0.386432</td>
      <td>4879.525433</td>
      <td>4338.198225</td>
      <td>0.149329</td>
      <td>-25.452324</td>
      <td>4600.907364</td>
      <td>-26.993645</td>
    </tr>
    <tr>
      <th>11</th>
      <td>CH4</td>
      <td>-161.490</td>
      <td>16.0</td>
      <td>0.000000</td>
      <td>-161.490</td>
      <td>16.0</td>
      <td>0.000000</td>
      <td>-74.5364</td>
      <td>-42.935</td>
      <td>-0.502432</td>
      <td>5555.674925</td>
      <td>1843.414225</td>
      <td>0.252438</td>
      <td>21.571905</td>
      <td>3200.220334</td>
      <td>37.449450</td>
    </tr>
    <tr>
      <th>12</th>
      <td>SiH4</td>
      <td>-111.800</td>
      <td>32.1</td>
      <td>0.000000</td>
      <td>-111.800</td>
      <td>32.1</td>
      <td>0.000000</td>
      <td>-24.8464</td>
      <td>-26.835</td>
      <td>-0.502432</td>
      <td>617.343593</td>
      <td>720.117225</td>
      <td>0.252438</td>
      <td>13.482755</td>
      <td>666.753144</td>
      <td>12.483619</td>
    </tr>
    <tr>
      <th>13</th>
      <td>GeH4</td>
      <td>-90.000</td>
      <td>76.6</td>
      <td>0.000000</td>
      <td>-90.000</td>
      <td>76.6</td>
      <td>0.000000</td>
      <td>-3.0464</td>
      <td>17.665</td>
      <td>-0.502432</td>
      <td>9.280553</td>
      <td>312.052225</td>
      <td>0.252438</td>
      <td>-8.875456</td>
      <td>-53.814656</td>
      <td>1.530608</td>
    </tr>
    <tr>
      <th>14</th>
      <td>SnH4</td>
      <td>-52.000</td>
      <td>122.7</td>
      <td>0.000000</td>
      <td>-52.000</td>
      <td>122.7</td>
      <td>0.000000</td>
      <td>34.9536</td>
      <td>63.765</td>
      <td>-0.502432</td>
      <td>1221.754153</td>
      <td>4065.975225</td>
      <td>0.252438</td>
      <td>-32.037557</td>
      <td>2228.816304</td>
      <td>-17.561797</td>
    </tr>
    <tr>
      <th>15</th>
      <td>He</td>
      <td>-268.934</td>
      <td>4.0</td>
      <td>0.000000</td>
      <td>-268.934</td>
      <td>4.0</td>
      <td>0.000000</td>
      <td>-181.9804</td>
      <td>-54.935</td>
      <td>-0.502432</td>
      <td>33116.865984</td>
      <td>3017.854225</td>
      <td>0.252438</td>
      <td>27.601085</td>
      <td>9997.093274</td>
      <td>91.432722</td>
    </tr>
    <tr>
      <th>16</th>
      <td>Ne</td>
      <td>-246.048</td>
      <td>20.2</td>
      <td>0.000000</td>
      <td>-246.048</td>
      <td>20.2</td>
      <td>0.000000</td>
      <td>-159.0944</td>
      <td>-38.735</td>
      <td>-0.502432</td>
      <td>25311.028111</td>
      <td>1500.400225</td>
      <td>0.252438</td>
      <td>19.461692</td>
      <td>6162.521584</td>
      <td>79.934070</td>
    </tr>
    <tr>
      <th>17</th>
      <td>Ar</td>
      <td>-185.700</td>
      <td>39.9</td>
      <td>0.000000</td>
      <td>-185.700</td>
      <td>39.9</td>
      <td>0.000000</td>
      <td>-98.7464</td>
      <td>-19.035</td>
      <td>-0.502432</td>
      <td>9750.851513</td>
      <td>362.331225</td>
      <td>0.252438</td>
      <td>9.563787</td>
      <td>1879.637724</td>
      <td>49.613322</td>
    </tr>
    <tr>
      <th>18</th>
      <td>Kr</td>
      <td>-152.300</td>
      <td>83.8</td>
      <td>0.000000</td>
      <td>-152.300</td>
      <td>83.8</td>
      <td>0.000000</td>
      <td>-65.3464</td>
      <td>24.865</td>
      <td>-0.502432</td>
      <td>4270.151993</td>
      <td>618.268225</td>
      <td>0.252438</td>
      <td>-12.492964</td>
      <td>-1624.838236</td>
      <td>32.832103</td>
    </tr>
    <tr>
      <th>19</th>
      <td>Xe</td>
      <td>-108.100</td>
      <td>131.3</td>
      <td>0.000000</td>
      <td>-108.100</td>
      <td>131.3</td>
      <td>0.000000</td>
      <td>-21.1464</td>
      <td>72.365</td>
      <td>-0.502432</td>
      <td>447.170233</td>
      <td>5236.693225</td>
      <td>0.252438</td>
      <td>-36.358470</td>
      <td>-1530.259236</td>
      <td>10.624622</td>
    </tr>
  </tbody>
</table>
</div>



<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>y</th>
      <th>x1</th>
      <th>x2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>mean</th>
      <td>-86.953600</td>
      <td>58.935000</td>
      <td>0.502432</td>
    </tr>
    <tr>
      <th>variance</th>
      <td>7057.696185</td>
      <td>1739.624275</td>
      <td>0.387350</td>
    </tr>
    <tr>
      <th>sd</th>
      <td>84.010096</td>
      <td>41.708803</td>
      <td>0.622375</td>
    </tr>
  </tbody>
</table>
</div>



<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>x1,x2</th>
      <th>x1,y</th>
      <th>x2,y</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>covariance</th>
      <td>-9.880045</td>
      <td>819.944636</td>
      <td>36.543167</td>
    </tr>
    <tr>
      <th>correlation</th>
      <td>-0.380609</td>
      <td>0.234005</td>
      <td>0.698912</td>
    </tr>
  </tbody>
</table>
</div>



<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>w1</th>
      <th>w2</th>
      <th>t</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>y = f(x) = w1x1 + w2x2 + t</th>
      <td>1.177751</td>
      <td>124.381955</td>
      <td>-218.857782</td>
    </tr>
  </tbody>
</table>
</div>



```python
def f(x1, x2):
    return w1 * x1 + w2 * x2 + t
```


```python
excel['f(x1,x2)'] = f(excel['x1'], excel['x2'])
display(excel, 
        pd.DataFrame([[mean_y, mean_x1, mean_x2], 
                      [variance_y, variance_x1, variance_x2], 
                      [sd_y, sd_x1, sd_x2]], 
                     columns=['y','x1', 'x2'], index=['mean', 'variance', 'sd']),
        pd.DataFrame([[covar_x1x2, covar_x1y, covar_x2y], [corr_x1x2, corr_x1y, corr_x2y]], 
                     index=['covariance', 'correlation'], columns=['x1,x2','x1,y', 'x2,y']),
        pd.DataFrame([[w1, w2, t]], columns=["w1", "w2", "t"], index=["y = f(x) = w1x1 + w2x2 + t"]))
```


<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>molecule</th>
      <th>boiling point</th>
      <th>molecular weight</th>
      <th>dipole monent</th>
      <th>y</th>
      <th>x1</th>
      <th>x2</th>
      <th>y-mean(y)</th>
      <th>x1-mean(x1)</th>
      <th>x2-mean(x2)</th>
      <th>(y-mean(y))**2</th>
      <th>(x1-mean(x1))**2</th>
      <th>(x2-mean(x2))**2</th>
      <th>(x1-mean(x1)) * (x2-mean(x2))</th>
      <th>(y-mean(y)) * (x1-mean(x1))</th>
      <th>(y-mean(y)) * (x2-mean(x2))</th>
      <th>f(x1,x2)</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>HF</td>
      <td>19.500</td>
      <td>20.0</td>
      <td>1.826567</td>
      <td>19.500</td>
      <td>20.0</td>
      <td>1.826567</td>
      <td>106.4536</td>
      <td>-38.935</td>
      <td>1.324135</td>
      <td>11332.368953</td>
      <td>1515.934225</td>
      <td>1.753334</td>
      <td>-51.555208</td>
      <td>-4144.770916</td>
      <td>140.958970</td>
      <td>31.889208</td>
    </tr>
    <tr>
      <th>1</th>
      <td>HCl</td>
      <td>-84.900</td>
      <td>36.5</td>
      <td>1.108600</td>
      <td>-84.900</td>
      <td>36.5</td>
      <td>1.108600</td>
      <td>2.0536</td>
      <td>-22.435</td>
      <td>0.606168</td>
      <td>4.217273</td>
      <td>503.329225</td>
      <td>0.367440</td>
      <td>-13.599386</td>
      <td>-46.072516</td>
      <td>1.244827</td>
      <td>-37.980042</td>
    </tr>
    <tr>
      <th>2</th>
      <td>HBr</td>
      <td>-67.000</td>
      <td>80.9</td>
      <td>0.827100</td>
      <td>-67.000</td>
      <td>80.9</td>
      <td>0.827100</td>
      <td>19.9536</td>
      <td>21.965</td>
      <td>0.324668</td>
      <td>398.146153</td>
      <td>482.461225</td>
      <td>0.105410</td>
      <td>7.131339</td>
      <td>438.280824</td>
      <td>6.478301</td>
      <td>-20.701425</td>
    </tr>
    <tr>
      <th>3</th>
      <td>HI</td>
      <td>-35.100</td>
      <td>127.9</td>
      <td>0.447700</td>
      <td>-35.100</td>
      <td>127.9</td>
      <td>0.447700</td>
      <td>51.8536</td>
      <td>68.965</td>
      <td>-0.054732</td>
      <td>2688.795833</td>
      <td>4756.171225</td>
      <td>0.002996</td>
      <td>-3.774572</td>
      <td>3576.083524</td>
      <td>-2.838036</td>
      <td>-12.537650</td>
    </tr>
    <tr>
      <th>4</th>
      <td>H2O</td>
      <td>100.000</td>
      <td>18.0</td>
      <td>1.854600</td>
      <td>100.000</td>
      <td>18.0</td>
      <td>1.854600</td>
      <td>186.9536</td>
      <td>-40.935</td>
      <td>1.352168</td>
      <td>34951.648553</td>
      <td>1675.674225</td>
      <td>1.828359</td>
      <td>-55.351009</td>
      <td>-7652.945616</td>
      <td>252.792731</td>
      <td>33.020506</td>
    </tr>
    <tr>
      <th>5</th>
      <td>H2S</td>
      <td>-60.700</td>
      <td>34.1</td>
      <td>0.978325</td>
      <td>-60.700</td>
      <td>34.1</td>
      <td>0.978325</td>
      <td>26.2536</td>
      <td>-24.835</td>
      <td>0.475893</td>
      <td>689.251513</td>
      <td>616.777225</td>
      <td>0.226474</td>
      <td>-11.818810</td>
      <td>-652.008156</td>
      <td>12.493912</td>
      <td>-57.010503</td>
    </tr>
    <tr>
      <th>6</th>
      <td>H2Se</td>
      <td>-42.000</td>
      <td>81.0</td>
      <td>0.627000</td>
      <td>-42.000</td>
      <td>81.0</td>
      <td>0.627000</td>
      <td>44.9536</td>
      <td>22.065</td>
      <td>0.124568</td>
      <td>2020.826153</td>
      <td>486.864225</td>
      <td>0.015517</td>
      <td>2.748600</td>
      <td>991.901184</td>
      <td>5.599794</td>
      <td>-45.472479</td>
    </tr>
    <tr>
      <th>7</th>
      <td>NH3</td>
      <td>-33.400</td>
      <td>17.0</td>
      <td>1.471772</td>
      <td>-33.400</td>
      <td>17.0</td>
      <td>1.471772</td>
      <td>53.5536</td>
      <td>-41.935</td>
      <td>0.969340</td>
      <td>2867.988073</td>
      <td>1758.544225</td>
      <td>0.939621</td>
      <td>-40.649285</td>
      <td>-2245.770216</td>
      <td>51.911663</td>
      <td>-15.774140</td>
    </tr>
    <tr>
      <th>8</th>
      <td>PH3</td>
      <td>-87.000</td>
      <td>34.0</td>
      <td>0.573970</td>
      <td>-87.000</td>
      <td>34.0</td>
      <td>0.573970</td>
      <td>-0.0464</td>
      <td>-24.935</td>
      <td>0.071538</td>
      <td>0.002153</td>
      <td>621.754225</td>
      <td>0.005118</td>
      <td>-1.783808</td>
      <td>1.156984</td>
      <td>-0.003319</td>
      <td>-107.422743</td>
    </tr>
    <tr>
      <th>9</th>
      <td>AsH3</td>
      <td>-55.000</td>
      <td>77.9</td>
      <td>0.217000</td>
      <td>-55.000</td>
      <td>77.9</td>
      <td>0.217000</td>
      <td>31.9536</td>
      <td>18.965</td>
      <td>-0.285432</td>
      <td>1021.032553</td>
      <td>359.671225</td>
      <td>0.081471</td>
      <td>-5.413212</td>
      <td>606.000024</td>
      <td>-9.120570</td>
      <td>-100.120108</td>
    </tr>
    <tr>
      <th>10</th>
      <td>SbH3</td>
      <td>-17.100</td>
      <td>124.8</td>
      <td>0.116000</td>
      <td>-17.100</td>
      <td>124.8</td>
      <td>0.116000</td>
      <td>69.8536</td>
      <td>65.865</td>
      <td>-0.386432</td>
      <td>4879.525433</td>
      <td>4338.198225</td>
      <td>0.149329</td>
      <td>-25.452324</td>
      <td>4600.907364</td>
      <td>-26.993645</td>
      <td>-57.446172</td>
    </tr>
    <tr>
      <th>11</th>
      <td>CH4</td>
      <td>-161.490</td>
      <td>16.0</td>
      <td>0.000000</td>
      <td>-161.490</td>
      <td>16.0</td>
      <td>0.000000</td>
      <td>-74.5364</td>
      <td>-42.935</td>
      <td>-0.502432</td>
      <td>5555.674925</td>
      <td>1843.414225</td>
      <td>0.252438</td>
      <td>21.571905</td>
      <td>3200.220334</td>
      <td>37.449450</td>
      <td>-200.013769</td>
    </tr>
    <tr>
      <th>12</th>
      <td>SiH4</td>
      <td>-111.800</td>
      <td>32.1</td>
      <td>0.000000</td>
      <td>-111.800</td>
      <td>32.1</td>
      <td>0.000000</td>
      <td>-24.8464</td>
      <td>-26.835</td>
      <td>-0.502432</td>
      <td>617.343593</td>
      <td>720.117225</td>
      <td>0.252438</td>
      <td>13.482755</td>
      <td>666.753144</td>
      <td>12.483619</td>
      <td>-181.051981</td>
    </tr>
    <tr>
      <th>13</th>
      <td>GeH4</td>
      <td>-90.000</td>
      <td>76.6</td>
      <td>0.000000</td>
      <td>-90.000</td>
      <td>76.6</td>
      <td>0.000000</td>
      <td>-3.0464</td>
      <td>17.665</td>
      <td>-0.502432</td>
      <td>9.280553</td>
      <td>312.052225</td>
      <td>0.252438</td>
      <td>-8.875456</td>
      <td>-53.814656</td>
      <td>1.530608</td>
      <td>-128.642069</td>
    </tr>
    <tr>
      <th>14</th>
      <td>SnH4</td>
      <td>-52.000</td>
      <td>122.7</td>
      <td>0.000000</td>
      <td>-52.000</td>
      <td>122.7</td>
      <td>0.000000</td>
      <td>34.9536</td>
      <td>63.765</td>
      <td>-0.502432</td>
      <td>1221.754153</td>
      <td>4065.975225</td>
      <td>0.252438</td>
      <td>-32.037557</td>
      <td>2228.816304</td>
      <td>-17.561797</td>
      <td>-74.347755</td>
    </tr>
    <tr>
      <th>15</th>
      <td>He</td>
      <td>-268.934</td>
      <td>4.0</td>
      <td>0.000000</td>
      <td>-268.934</td>
      <td>4.0</td>
      <td>0.000000</td>
      <td>-181.9804</td>
      <td>-54.935</td>
      <td>-0.502432</td>
      <td>33116.865984</td>
      <td>3017.854225</td>
      <td>0.252438</td>
      <td>27.601085</td>
      <td>9997.093274</td>
      <td>91.432722</td>
      <td>-214.146779</td>
    </tr>
    <tr>
      <th>16</th>
      <td>Ne</td>
      <td>-246.048</td>
      <td>20.2</td>
      <td>0.000000</td>
      <td>-246.048</td>
      <td>20.2</td>
      <td>0.000000</td>
      <td>-159.0944</td>
      <td>-38.735</td>
      <td>-0.502432</td>
      <td>25311.028111</td>
      <td>1500.400225</td>
      <td>0.252438</td>
      <td>19.461692</td>
      <td>6162.521584</td>
      <td>79.934070</td>
      <td>-195.067215</td>
    </tr>
    <tr>
      <th>17</th>
      <td>Ar</td>
      <td>-185.700</td>
      <td>39.9</td>
      <td>0.000000</td>
      <td>-185.700</td>
      <td>39.9</td>
      <td>0.000000</td>
      <td>-98.7464</td>
      <td>-19.035</td>
      <td>-0.502432</td>
      <td>9750.851513</td>
      <td>362.331225</td>
      <td>0.252438</td>
      <td>9.563787</td>
      <td>1879.637724</td>
      <td>49.613322</td>
      <td>-171.865524</td>
    </tr>
    <tr>
      <th>18</th>
      <td>Kr</td>
      <td>-152.300</td>
      <td>83.8</td>
      <td>0.000000</td>
      <td>-152.300</td>
      <td>83.8</td>
      <td>0.000000</td>
      <td>-65.3464</td>
      <td>24.865</td>
      <td>-0.502432</td>
      <td>4270.151993</td>
      <td>618.268225</td>
      <td>0.252438</td>
      <td>-12.492964</td>
      <td>-1624.838236</td>
      <td>32.832103</td>
      <td>-120.162263</td>
    </tr>
    <tr>
      <th>19</th>
      <td>Xe</td>
      <td>-108.100</td>
      <td>131.3</td>
      <td>0.000000</td>
      <td>-108.100</td>
      <td>131.3</td>
      <td>0.000000</td>
      <td>-21.1464</td>
      <td>72.365</td>
      <td>-0.502432</td>
      <td>447.170233</td>
      <td>5236.693225</td>
      <td>0.252438</td>
      <td>-36.358470</td>
      <td>-1530.259236</td>
      <td>10.624622</td>
      <td>-64.219098</td>
    </tr>
  </tbody>
</table>
</div>



<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>y</th>
      <th>x1</th>
      <th>x2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>mean</th>
      <td>-86.953600</td>
      <td>58.935000</td>
      <td>0.502432</td>
    </tr>
    <tr>
      <th>variance</th>
      <td>7057.696185</td>
      <td>1739.624275</td>
      <td>0.387350</td>
    </tr>
    <tr>
      <th>sd</th>
      <td>84.010096</td>
      <td>41.708803</td>
      <td>0.622375</td>
    </tr>
  </tbody>
</table>
</div>



<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>x1,x2</th>
      <th>x1,y</th>
      <th>x2,y</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>covariance</th>
      <td>-9.880045</td>
      <td>819.944636</td>
      <td>36.543167</td>
    </tr>
    <tr>
      <th>correlation</th>
      <td>-0.380609</td>
      <td>0.234005</td>
      <td>0.698912</td>
    </tr>
  </tbody>
</table>
</div>



<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>w1</th>
      <th>w2</th>
      <th>t</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>y = f(x) = w1x1 + w2x2 + t</th>
      <td>1.177751</td>
      <td>124.381955</td>
      <td>-218.857782</td>
    </tr>
  </tbody>
</table>
</div>



```python
excel['(y-f(x1,x2))**2'] = (excel['y'] - excel['f(x1,x2)'])**2
display(excel, 
        pd.DataFrame([[mean_y, mean_x1, mean_x2], 
                      [variance_y, variance_x1, variance_x2], 
                      [sd_y, sd_x1, sd_x2]], 
                     columns=['y','x1', 'x2'], index=['mean', 'variance', 'sd']),
        pd.DataFrame([[covar_x1x2, covar_x1y, covar_x2y], [corr_x1x2, corr_x1y, corr_x2y]], 
                     index=['covariance', 'correlation'], columns=['x1,x2','x1,y', 'x2,y']),
        pd.DataFrame([[w1, w2, t]], columns=["w1", "w2", "t"], index=["y = f(x) = w1x1 + w2x2 + t"]))
```


<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>molecule</th>
      <th>boiling point</th>
      <th>molecular weight</th>
      <th>dipole monent</th>
      <th>y</th>
      <th>x1</th>
      <th>x2</th>
      <th>y-mean(y)</th>
      <th>x1-mean(x1)</th>
      <th>x2-mean(x2)</th>
      <th>(y-mean(y))**2</th>
      <th>(x1-mean(x1))**2</th>
      <th>(x2-mean(x2))**2</th>
      <th>(x1-mean(x1)) * (x2-mean(x2))</th>
      <th>(y-mean(y)) * (x1-mean(x1))</th>
      <th>(y-mean(y)) * (x2-mean(x2))</th>
      <th>f(x1,x2)</th>
      <th>(y-f(x1,x2))**2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>HF</td>
      <td>19.500</td>
      <td>20.0</td>
      <td>1.826567</td>
      <td>19.500</td>
      <td>20.0</td>
      <td>1.826567</td>
      <td>106.4536</td>
      <td>-38.935</td>
      <td>1.324135</td>
      <td>11332.368953</td>
      <td>1515.934225</td>
      <td>1.753334</td>
      <td>-51.555208</td>
      <td>-4144.770916</td>
      <td>140.958970</td>
      <td>31.889208</td>
      <td>153.492486</td>
    </tr>
    <tr>
      <th>1</th>
      <td>HCl</td>
      <td>-84.900</td>
      <td>36.5</td>
      <td>1.108600</td>
      <td>-84.900</td>
      <td>36.5</td>
      <td>1.108600</td>
      <td>2.0536</td>
      <td>-22.435</td>
      <td>0.606168</td>
      <td>4.217273</td>
      <td>503.329225</td>
      <td>0.367440</td>
      <td>-13.599386</td>
      <td>-46.072516</td>
      <td>1.244827</td>
      <td>-37.980042</td>
      <td>2201.482478</td>
    </tr>
    <tr>
      <th>2</th>
      <td>HBr</td>
      <td>-67.000</td>
      <td>80.9</td>
      <td>0.827100</td>
      <td>-67.000</td>
      <td>80.9</td>
      <td>0.827100</td>
      <td>19.9536</td>
      <td>21.965</td>
      <td>0.324668</td>
      <td>398.146153</td>
      <td>482.461225</td>
      <td>0.105410</td>
      <td>7.131339</td>
      <td>438.280824</td>
      <td>6.478301</td>
      <td>-20.701425</td>
      <td>2143.558032</td>
    </tr>
    <tr>
      <th>3</th>
      <td>HI</td>
      <td>-35.100</td>
      <td>127.9</td>
      <td>0.447700</td>
      <td>-35.100</td>
      <td>127.9</td>
      <td>0.447700</td>
      <td>51.8536</td>
      <td>68.965</td>
      <td>-0.054732</td>
      <td>2688.795833</td>
      <td>4756.171225</td>
      <td>0.002996</td>
      <td>-3.774572</td>
      <td>3576.083524</td>
      <td>-2.838036</td>
      <td>-12.537650</td>
      <td>509.059649</td>
    </tr>
    <tr>
      <th>4</th>
      <td>H2O</td>
      <td>100.000</td>
      <td>18.0</td>
      <td>1.854600</td>
      <td>100.000</td>
      <td>18.0</td>
      <td>1.854600</td>
      <td>186.9536</td>
      <td>-40.935</td>
      <td>1.352168</td>
      <td>34951.648553</td>
      <td>1675.674225</td>
      <td>1.828359</td>
      <td>-55.351009</td>
      <td>-7652.945616</td>
      <td>252.792731</td>
      <td>33.020506</td>
      <td>4486.252600</td>
    </tr>
    <tr>
      <th>5</th>
      <td>H2S</td>
      <td>-60.700</td>
      <td>34.1</td>
      <td>0.978325</td>
      <td>-60.700</td>
      <td>34.1</td>
      <td>0.978325</td>
      <td>26.2536</td>
      <td>-24.835</td>
      <td>0.475893</td>
      <td>689.251513</td>
      <td>616.777225</td>
      <td>0.226474</td>
      <td>-11.818810</td>
      <td>-652.008156</td>
      <td>12.493912</td>
      <td>-57.010503</td>
      <td>13.612388</td>
    </tr>
    <tr>
      <th>6</th>
      <td>H2Se</td>
      <td>-42.000</td>
      <td>81.0</td>
      <td>0.627000</td>
      <td>-42.000</td>
      <td>81.0</td>
      <td>0.627000</td>
      <td>44.9536</td>
      <td>22.065</td>
      <td>0.124568</td>
      <td>2020.826153</td>
      <td>486.864225</td>
      <td>0.015517</td>
      <td>2.748600</td>
      <td>991.901184</td>
      <td>5.599794</td>
      <td>-45.472479</td>
      <td>12.058112</td>
    </tr>
    <tr>
      <th>7</th>
      <td>NH3</td>
      <td>-33.400</td>
      <td>17.0</td>
      <td>1.471772</td>
      <td>-33.400</td>
      <td>17.0</td>
      <td>1.471772</td>
      <td>53.5536</td>
      <td>-41.935</td>
      <td>0.969340</td>
      <td>2867.988073</td>
      <td>1758.544225</td>
      <td>0.939621</td>
      <td>-40.649285</td>
      <td>-2245.770216</td>
      <td>51.911663</td>
      <td>-15.774140</td>
      <td>310.670951</td>
    </tr>
    <tr>
      <th>8</th>
      <td>PH3</td>
      <td>-87.000</td>
      <td>34.0</td>
      <td>0.573970</td>
      <td>-87.000</td>
      <td>34.0</td>
      <td>0.573970</td>
      <td>-0.0464</td>
      <td>-24.935</td>
      <td>0.071538</td>
      <td>0.002153</td>
      <td>621.754225</td>
      <td>0.005118</td>
      <td>-1.783808</td>
      <td>1.156984</td>
      <td>-0.003319</td>
      <td>-107.422743</td>
      <td>417.088447</td>
    </tr>
    <tr>
      <th>9</th>
      <td>AsH3</td>
      <td>-55.000</td>
      <td>77.9</td>
      <td>0.217000</td>
      <td>-55.000</td>
      <td>77.9</td>
      <td>0.217000</td>
      <td>31.9536</td>
      <td>18.965</td>
      <td>-0.285432</td>
      <td>1021.032553</td>
      <td>359.671225</td>
      <td>0.081471</td>
      <td>-5.413212</td>
      <td>606.000024</td>
      <td>-9.120570</td>
      <td>-100.120108</td>
      <td>2035.824173</td>
    </tr>
    <tr>
      <th>10</th>
      <td>SbH3</td>
      <td>-17.100</td>
      <td>124.8</td>
      <td>0.116000</td>
      <td>-17.100</td>
      <td>124.8</td>
      <td>0.116000</td>
      <td>69.8536</td>
      <td>65.865</td>
      <td>-0.386432</td>
      <td>4879.525433</td>
      <td>4338.198225</td>
      <td>0.149329</td>
      <td>-25.452324</td>
      <td>4600.907364</td>
      <td>-26.993645</td>
      <td>-57.446172</td>
      <td>1627.813574</td>
    </tr>
    <tr>
      <th>11</th>
      <td>CH4</td>
      <td>-161.490</td>
      <td>16.0</td>
      <td>0.000000</td>
      <td>-161.490</td>
      <td>16.0</td>
      <td>0.000000</td>
      <td>-74.5364</td>
      <td>-42.935</td>
      <td>-0.502432</td>
      <td>5555.674925</td>
      <td>1843.414225</td>
      <td>0.252438</td>
      <td>21.571905</td>
      <td>3200.220334</td>
      <td>37.449450</td>
      <td>-200.013769</td>
      <td>1484.080775</td>
    </tr>
    <tr>
      <th>12</th>
      <td>SiH4</td>
      <td>-111.800</td>
      <td>32.1</td>
      <td>0.000000</td>
      <td>-111.800</td>
      <td>32.1</td>
      <td>0.000000</td>
      <td>-24.8464</td>
      <td>-26.835</td>
      <td>-0.502432</td>
      <td>617.343593</td>
      <td>720.117225</td>
      <td>0.252438</td>
      <td>13.482755</td>
      <td>666.753144</td>
      <td>12.483619</td>
      <td>-181.051981</td>
      <td>4795.836813</td>
    </tr>
    <tr>
      <th>13</th>
      <td>GeH4</td>
      <td>-90.000</td>
      <td>76.6</td>
      <td>0.000000</td>
      <td>-90.000</td>
      <td>76.6</td>
      <td>0.000000</td>
      <td>-3.0464</td>
      <td>17.665</td>
      <td>-0.502432</td>
      <td>9.280553</td>
      <td>312.052225</td>
      <td>0.252438</td>
      <td>-8.875456</td>
      <td>-53.814656</td>
      <td>1.530608</td>
      <td>-128.642069</td>
      <td>1493.209464</td>
    </tr>
    <tr>
      <th>14</th>
      <td>SnH4</td>
      <td>-52.000</td>
      <td>122.7</td>
      <td>0.000000</td>
      <td>-52.000</td>
      <td>122.7</td>
      <td>0.000000</td>
      <td>34.9536</td>
      <td>63.765</td>
      <td>-0.502432</td>
      <td>1221.754153</td>
      <td>4065.975225</td>
      <td>0.252438</td>
      <td>-32.037557</td>
      <td>2228.816304</td>
      <td>-17.561797</td>
      <td>-74.347755</td>
      <td>499.422165</td>
    </tr>
    <tr>
      <th>15</th>
      <td>He</td>
      <td>-268.934</td>
      <td>4.0</td>
      <td>0.000000</td>
      <td>-268.934</td>
      <td>4.0</td>
      <td>0.000000</td>
      <td>-181.9804</td>
      <td>-54.935</td>
      <td>-0.502432</td>
      <td>33116.865984</td>
      <td>3017.854225</td>
      <td>0.252438</td>
      <td>27.601085</td>
      <td>9997.093274</td>
      <td>91.432722</td>
      <td>-214.146779</td>
      <td>3001.639592</td>
    </tr>
    <tr>
      <th>16</th>
      <td>Ne</td>
      <td>-246.048</td>
      <td>20.2</td>
      <td>0.000000</td>
      <td>-246.048</td>
      <td>20.2</td>
      <td>0.000000</td>
      <td>-159.0944</td>
      <td>-38.735</td>
      <td>-0.502432</td>
      <td>25311.028111</td>
      <td>1500.400225</td>
      <td>0.252438</td>
      <td>19.461692</td>
      <td>6162.521584</td>
      <td>79.934070</td>
      <td>-195.067215</td>
      <td>2599.040392</td>
    </tr>
    <tr>
      <th>17</th>
      <td>Ar</td>
      <td>-185.700</td>
      <td>39.9</td>
      <td>0.000000</td>
      <td>-185.700</td>
      <td>39.9</td>
      <td>0.000000</td>
      <td>-98.7464</td>
      <td>-19.035</td>
      <td>-0.502432</td>
      <td>9750.851513</td>
      <td>362.331225</td>
      <td>0.252438</td>
      <td>9.563787</td>
      <td>1879.637724</td>
      <td>49.613322</td>
      <td>-171.865524</td>
      <td>191.392724</td>
    </tr>
    <tr>
      <th>18</th>
      <td>Kr</td>
      <td>-152.300</td>
      <td>83.8</td>
      <td>0.000000</td>
      <td>-152.300</td>
      <td>83.8</td>
      <td>0.000000</td>
      <td>-65.3464</td>
      <td>24.865</td>
      <td>-0.502432</td>
      <td>4270.151993</td>
      <td>618.268225</td>
      <td>0.252438</td>
      <td>-12.492964</td>
      <td>-1624.838236</td>
      <td>32.832103</td>
      <td>-120.162263</td>
      <td>1032.834166</td>
    </tr>
    <tr>
      <th>19</th>
      <td>Xe</td>
      <td>-108.100</td>
      <td>131.3</td>
      <td>0.000000</td>
      <td>-108.100</td>
      <td>131.3</td>
      <td>0.000000</td>
      <td>-21.1464</td>
      <td>72.365</td>
      <td>-0.502432</td>
      <td>447.170233</td>
      <td>5236.693225</td>
      <td>0.252438</td>
      <td>-36.358470</td>
      <td>-1530.259236</td>
      <td>10.624622</td>
      <td>-64.219098</td>
      <td>1925.533552</td>
    </tr>
  </tbody>
</table>
</div>



<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>y</th>
      <th>x1</th>
      <th>x2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>mean</th>
      <td>-86.953600</td>
      <td>58.935000</td>
      <td>0.502432</td>
    </tr>
    <tr>
      <th>variance</th>
      <td>7057.696185</td>
      <td>1739.624275</td>
      <td>0.387350</td>
    </tr>
    <tr>
      <th>sd</th>
      <td>84.010096</td>
      <td>41.708803</td>
      <td>0.622375</td>
    </tr>
  </tbody>
</table>
</div>



<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>x1,x2</th>
      <th>x1,y</th>
      <th>x2,y</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>covariance</th>
      <td>-9.880045</td>
      <td>819.944636</td>
      <td>36.543167</td>
    </tr>
    <tr>
      <th>correlation</th>
      <td>-0.380609</td>
      <td>0.234005</td>
      <td>0.698912</td>
    </tr>
  </tbody>
</table>
</div>



<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>w1</th>
      <th>w2</th>
      <th>t</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>y = f(x) = w1x1 + w2x2 + t</th>
      <td>1.177751</td>
      <td>124.381955</td>
      <td>-218.857782</td>
    </tr>
  </tbody>
</table>
</div>



```python
r2 = 1. - sum(excel['(y-f(x1,x2))**2']) / sum(excel['(y-mean(y))**2'])
display(excel, 
        pd.DataFrame([[mean_y, mean_x1, mean_x2], 
                      [variance_y, variance_x1, variance_x2], 
                      [sd_y, sd_x1, sd_x2]], 
                     columns=['y','x1', 'x2'], index=['mean', 'variance', 'sd']),
        pd.DataFrame([[covar_x1x2, covar_x1y, covar_x2y], [corr_x1x2, corr_x1y, corr_x2y]], 
                     index=['covariance', 'correlation'], columns=['x1,x2','x1,y', 'x2,y']),
        pd.DataFrame([[w1, w2, t, r2]], columns=["w1", "w2", "t", "r2"], index=["y = f(x) = w1x1 + w2x2 + t"]))
```


<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>molecule</th>
      <th>boiling point</th>
      <th>molecular weight</th>
      <th>dipole monent</th>
      <th>y</th>
      <th>x1</th>
      <th>x2</th>
      <th>y-mean(y)</th>
      <th>x1-mean(x1)</th>
      <th>x2-mean(x2)</th>
      <th>(y-mean(y))**2</th>
      <th>(x1-mean(x1))**2</th>
      <th>(x2-mean(x2))**2</th>
      <th>(x1-mean(x1)) * (x2-mean(x2))</th>
      <th>(y-mean(y)) * (x1-mean(x1))</th>
      <th>(y-mean(y)) * (x2-mean(x2))</th>
      <th>f(x1,x2)</th>
      <th>(y-f(x1,x2))**2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>0</th>
      <td>HF</td>
      <td>19.500</td>
      <td>20.0</td>
      <td>1.826567</td>
      <td>19.500</td>
      <td>20.0</td>
      <td>1.826567</td>
      <td>106.4536</td>
      <td>-38.935</td>
      <td>1.324135</td>
      <td>11332.368953</td>
      <td>1515.934225</td>
      <td>1.753334</td>
      <td>-51.555208</td>
      <td>-4144.770916</td>
      <td>140.958970</td>
      <td>31.889208</td>
      <td>153.492486</td>
    </tr>
    <tr>
      <th>1</th>
      <td>HCl</td>
      <td>-84.900</td>
      <td>36.5</td>
      <td>1.108600</td>
      <td>-84.900</td>
      <td>36.5</td>
      <td>1.108600</td>
      <td>2.0536</td>
      <td>-22.435</td>
      <td>0.606168</td>
      <td>4.217273</td>
      <td>503.329225</td>
      <td>0.367440</td>
      <td>-13.599386</td>
      <td>-46.072516</td>
      <td>1.244827</td>
      <td>-37.980042</td>
      <td>2201.482478</td>
    </tr>
    <tr>
      <th>2</th>
      <td>HBr</td>
      <td>-67.000</td>
      <td>80.9</td>
      <td>0.827100</td>
      <td>-67.000</td>
      <td>80.9</td>
      <td>0.827100</td>
      <td>19.9536</td>
      <td>21.965</td>
      <td>0.324668</td>
      <td>398.146153</td>
      <td>482.461225</td>
      <td>0.105410</td>
      <td>7.131339</td>
      <td>438.280824</td>
      <td>6.478301</td>
      <td>-20.701425</td>
      <td>2143.558032</td>
    </tr>
    <tr>
      <th>3</th>
      <td>HI</td>
      <td>-35.100</td>
      <td>127.9</td>
      <td>0.447700</td>
      <td>-35.100</td>
      <td>127.9</td>
      <td>0.447700</td>
      <td>51.8536</td>
      <td>68.965</td>
      <td>-0.054732</td>
      <td>2688.795833</td>
      <td>4756.171225</td>
      <td>0.002996</td>
      <td>-3.774572</td>
      <td>3576.083524</td>
      <td>-2.838036</td>
      <td>-12.537650</td>
      <td>509.059649</td>
    </tr>
    <tr>
      <th>4</th>
      <td>H2O</td>
      <td>100.000</td>
      <td>18.0</td>
      <td>1.854600</td>
      <td>100.000</td>
      <td>18.0</td>
      <td>1.854600</td>
      <td>186.9536</td>
      <td>-40.935</td>
      <td>1.352168</td>
      <td>34951.648553</td>
      <td>1675.674225</td>
      <td>1.828359</td>
      <td>-55.351009</td>
      <td>-7652.945616</td>
      <td>252.792731</td>
      <td>33.020506</td>
      <td>4486.252600</td>
    </tr>
    <tr>
      <th>5</th>
      <td>H2S</td>
      <td>-60.700</td>
      <td>34.1</td>
      <td>0.978325</td>
      <td>-60.700</td>
      <td>34.1</td>
      <td>0.978325</td>
      <td>26.2536</td>
      <td>-24.835</td>
      <td>0.475893</td>
      <td>689.251513</td>
      <td>616.777225</td>
      <td>0.226474</td>
      <td>-11.818810</td>
      <td>-652.008156</td>
      <td>12.493912</td>
      <td>-57.010503</td>
      <td>13.612388</td>
    </tr>
    <tr>
      <th>6</th>
      <td>H2Se</td>
      <td>-42.000</td>
      <td>81.0</td>
      <td>0.627000</td>
      <td>-42.000</td>
      <td>81.0</td>
      <td>0.627000</td>
      <td>44.9536</td>
      <td>22.065</td>
      <td>0.124568</td>
      <td>2020.826153</td>
      <td>486.864225</td>
      <td>0.015517</td>
      <td>2.748600</td>
      <td>991.901184</td>
      <td>5.599794</td>
      <td>-45.472479</td>
      <td>12.058112</td>
    </tr>
    <tr>
      <th>7</th>
      <td>NH3</td>
      <td>-33.400</td>
      <td>17.0</td>
      <td>1.471772</td>
      <td>-33.400</td>
      <td>17.0</td>
      <td>1.471772</td>
      <td>53.5536</td>
      <td>-41.935</td>
      <td>0.969340</td>
      <td>2867.988073</td>
      <td>1758.544225</td>
      <td>0.939621</td>
      <td>-40.649285</td>
      <td>-2245.770216</td>
      <td>51.911663</td>
      <td>-15.774140</td>
      <td>310.670951</td>
    </tr>
    <tr>
      <th>8</th>
      <td>PH3</td>
      <td>-87.000</td>
      <td>34.0</td>
      <td>0.573970</td>
      <td>-87.000</td>
      <td>34.0</td>
      <td>0.573970</td>
      <td>-0.0464</td>
      <td>-24.935</td>
      <td>0.071538</td>
      <td>0.002153</td>
      <td>621.754225</td>
      <td>0.005118</td>
      <td>-1.783808</td>
      <td>1.156984</td>
      <td>-0.003319</td>
      <td>-107.422743</td>
      <td>417.088447</td>
    </tr>
    <tr>
      <th>9</th>
      <td>AsH3</td>
      <td>-55.000</td>
      <td>77.9</td>
      <td>0.217000</td>
      <td>-55.000</td>
      <td>77.9</td>
      <td>0.217000</td>
      <td>31.9536</td>
      <td>18.965</td>
      <td>-0.285432</td>
      <td>1021.032553</td>
      <td>359.671225</td>
      <td>0.081471</td>
      <td>-5.413212</td>
      <td>606.000024</td>
      <td>-9.120570</td>
      <td>-100.120108</td>
      <td>2035.824173</td>
    </tr>
    <tr>
      <th>10</th>
      <td>SbH3</td>
      <td>-17.100</td>
      <td>124.8</td>
      <td>0.116000</td>
      <td>-17.100</td>
      <td>124.8</td>
      <td>0.116000</td>
      <td>69.8536</td>
      <td>65.865</td>
      <td>-0.386432</td>
      <td>4879.525433</td>
      <td>4338.198225</td>
      <td>0.149329</td>
      <td>-25.452324</td>
      <td>4600.907364</td>
      <td>-26.993645</td>
      <td>-57.446172</td>
      <td>1627.813574</td>
    </tr>
    <tr>
      <th>11</th>
      <td>CH4</td>
      <td>-161.490</td>
      <td>16.0</td>
      <td>0.000000</td>
      <td>-161.490</td>
      <td>16.0</td>
      <td>0.000000</td>
      <td>-74.5364</td>
      <td>-42.935</td>
      <td>-0.502432</td>
      <td>5555.674925</td>
      <td>1843.414225</td>
      <td>0.252438</td>
      <td>21.571905</td>
      <td>3200.220334</td>
      <td>37.449450</td>
      <td>-200.013769</td>
      <td>1484.080775</td>
    </tr>
    <tr>
      <th>12</th>
      <td>SiH4</td>
      <td>-111.800</td>
      <td>32.1</td>
      <td>0.000000</td>
      <td>-111.800</td>
      <td>32.1</td>
      <td>0.000000</td>
      <td>-24.8464</td>
      <td>-26.835</td>
      <td>-0.502432</td>
      <td>617.343593</td>
      <td>720.117225</td>
      <td>0.252438</td>
      <td>13.482755</td>
      <td>666.753144</td>
      <td>12.483619</td>
      <td>-181.051981</td>
      <td>4795.836813</td>
    </tr>
    <tr>
      <th>13</th>
      <td>GeH4</td>
      <td>-90.000</td>
      <td>76.6</td>
      <td>0.000000</td>
      <td>-90.000</td>
      <td>76.6</td>
      <td>0.000000</td>
      <td>-3.0464</td>
      <td>17.665</td>
      <td>-0.502432</td>
      <td>9.280553</td>
      <td>312.052225</td>
      <td>0.252438</td>
      <td>-8.875456</td>
      <td>-53.814656</td>
      <td>1.530608</td>
      <td>-128.642069</td>
      <td>1493.209464</td>
    </tr>
    <tr>
      <th>14</th>
      <td>SnH4</td>
      <td>-52.000</td>
      <td>122.7</td>
      <td>0.000000</td>
      <td>-52.000</td>
      <td>122.7</td>
      <td>0.000000</td>
      <td>34.9536</td>
      <td>63.765</td>
      <td>-0.502432</td>
      <td>1221.754153</td>
      <td>4065.975225</td>
      <td>0.252438</td>
      <td>-32.037557</td>
      <td>2228.816304</td>
      <td>-17.561797</td>
      <td>-74.347755</td>
      <td>499.422165</td>
    </tr>
    <tr>
      <th>15</th>
      <td>He</td>
      <td>-268.934</td>
      <td>4.0</td>
      <td>0.000000</td>
      <td>-268.934</td>
      <td>4.0</td>
      <td>0.000000</td>
      <td>-181.9804</td>
      <td>-54.935</td>
      <td>-0.502432</td>
      <td>33116.865984</td>
      <td>3017.854225</td>
      <td>0.252438</td>
      <td>27.601085</td>
      <td>9997.093274</td>
      <td>91.432722</td>
      <td>-214.146779</td>
      <td>3001.639592</td>
    </tr>
    <tr>
      <th>16</th>
      <td>Ne</td>
      <td>-246.048</td>
      <td>20.2</td>
      <td>0.000000</td>
      <td>-246.048</td>
      <td>20.2</td>
      <td>0.000000</td>
      <td>-159.0944</td>
      <td>-38.735</td>
      <td>-0.502432</td>
      <td>25311.028111</td>
      <td>1500.400225</td>
      <td>0.252438</td>
      <td>19.461692</td>
      <td>6162.521584</td>
      <td>79.934070</td>
      <td>-195.067215</td>
      <td>2599.040392</td>
    </tr>
    <tr>
      <th>17</th>
      <td>Ar</td>
      <td>-185.700</td>
      <td>39.9</td>
      <td>0.000000</td>
      <td>-185.700</td>
      <td>39.9</td>
      <td>0.000000</td>
      <td>-98.7464</td>
      <td>-19.035</td>
      <td>-0.502432</td>
      <td>9750.851513</td>
      <td>362.331225</td>
      <td>0.252438</td>
      <td>9.563787</td>
      <td>1879.637724</td>
      <td>49.613322</td>
      <td>-171.865524</td>
      <td>191.392724</td>
    </tr>
    <tr>
      <th>18</th>
      <td>Kr</td>
      <td>-152.300</td>
      <td>83.8</td>
      <td>0.000000</td>
      <td>-152.300</td>
      <td>83.8</td>
      <td>0.000000</td>
      <td>-65.3464</td>
      <td>24.865</td>
      <td>-0.502432</td>
      <td>4270.151993</td>
      <td>618.268225</td>
      <td>0.252438</td>
      <td>-12.492964</td>
      <td>-1624.838236</td>
      <td>32.832103</td>
      <td>-120.162263</td>
      <td>1032.834166</td>
    </tr>
    <tr>
      <th>19</th>
      <td>Xe</td>
      <td>-108.100</td>
      <td>131.3</td>
      <td>0.000000</td>
      <td>-108.100</td>
      <td>131.3</td>
      <td>0.000000</td>
      <td>-21.1464</td>
      <td>72.365</td>
      <td>-0.502432</td>
      <td>447.170233</td>
      <td>5236.693225</td>
      <td>0.252438</td>
      <td>-36.358470</td>
      <td>-1530.259236</td>
      <td>10.624622</td>
      <td>-64.219098</td>
      <td>1925.533552</td>
    </tr>
  </tbody>
</table>
</div>



<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>y</th>
      <th>x1</th>
      <th>x2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>mean</th>
      <td>-86.953600</td>
      <td>58.935000</td>
      <td>0.502432</td>
    </tr>
    <tr>
      <th>variance</th>
      <td>7057.696185</td>
      <td>1739.624275</td>
      <td>0.387350</td>
    </tr>
    <tr>
      <th>sd</th>
      <td>84.010096</td>
      <td>41.708803</td>
      <td>0.622375</td>
    </tr>
  </tbody>
</table>
</div>



<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>x1,x2</th>
      <th>x1,y</th>
      <th>x2,y</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>covariance</th>
      <td>-9.880045</td>
      <td>819.944636</td>
      <td>36.543167</td>
    </tr>
    <tr>
      <th>correlation</th>
      <td>-0.380609</td>
      <td>0.234005</td>
      <td>0.698912</td>
    </tr>
  </tbody>
</table>
</div>



<div>
<table border="1" class="dataframe">
  <thead>
    <tr style="text-align: right;">
      <th></th>
      <th>w1</th>
      <th>w2</th>
      <th>t</th>
      <th>r2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>y = f(x) = w1x1 + w2x2 + t</th>
      <td>1.177751</td>
      <td>124.381955</td>
      <td>-218.857782</td>
      <td>0.78085</td>
    </tr>
  </tbody>
</table>
</div>


できたっ！