small update again, code not working yet

This commit is contained in:
mhjensen
2018-05-14 17:27:25 -04:00
parent 5be0723b93
commit 33410db2f9
+12 -3
View File
@@ -269,7 +269,7 @@ meaning that the solution for $\hat{\beta}$ is the one which minimizes the resid
!split
===== Simple regression model =====
We are now ready to write our first program which aims at solving the above linear regression equations. We start with data we have produced ourselves, in this case normally distributed random numbers along the $x$-axis. These numbers define then the value of a function $y(x)=4+3x+N(0,1)$. Thereafter we order the $x$ values and employ
We are now ready to write our first program which aims at solving the above linear regression equations. We start with data we have produced ourselves, in this case normally distributed random numbers along the $x$-axis. These numbers define then the value of a function $y(x)=4+3x+N(0,1)$. Thereafter we order the $x$ values and employ our linear regression algorithm to set up the best fit.
!bc pycod
# Importing various packages
@@ -303,7 +303,7 @@ plt.show()
!split
===== Simple regression model, now using _scikit-learn_ =====
Add info about the equations
We can repeat the above algorithm using _scikit-learn_ as follows.
!bc pycod
# Importing various packages
from random import random, seed
@@ -328,8 +328,17 @@ plt.show()
!ec
!split
===== Correlations and the quality of our results =====
In order to test the quality of our fit, there are several measures which can be implemented. One is the so-called
correlation function defined as
!bt
\[
\mathrm{Corr}(X,Y) = \frac{\sum_{i=1}^n(x_i-\overline{x})(y_i-\overline{y})}{\sqrt{\sum_{i=1}^n(x_i-\overline{x})^2}\sqrt{\sum_{i=1}^n(y_i-\overline{y})^2} }
\]
!et
Another quantity is the autocorrelation function we discussed in our chapter on statistical analysis.
!split
===== The $\chi^2$ function =====