typos
This commit is contained in:
@@ -781,7 +781,7 @@ Note that the function _multivariate_ returns also the covariance discussed abov
|
||||
!bc pycod
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
import matplotlib as plt
|
||||
import matplotlib.pyplot as plt
|
||||
from IPython.display import display
|
||||
n = 10000
|
||||
mean = (-1, 2)
|
||||
@@ -844,7 +844,8 @@ print(np.cov(X_centered.T))
|
||||
Note that the way we define the covariance matrix here has a factor $n-1$ instead of $n$.
|
||||
Our own code here is not very elegant and asks for improvements.
|
||||
!bc pycod
|
||||
# extract the relevant columns from the centered design matrix of dim n x 2 x = X_centered[:,0]
|
||||
# extract the relevant columns from the centered design matrix of dim n x 2
|
||||
x = X_centered[:,0]
|
||||
y = X_centered[:,1]
|
||||
Cov = np.zeros((2,2))
|
||||
Cov[0,1] = np.sum(x.T@y)/(n-1.0)
|
||||
|
||||
Reference in New Issue
Block a user