Skip to content
Advertisement

Tag: matrix-multiplication

Centering matrix

I want to write a function for centering an input data matrix by multiplying it with the centering matrix. The function shall subtract the row-wise mean from the input. My code: But I get a wrong result matrix, it is not centered. Thanks! Answer The centering matrix is Here is a list of issues in your original formulation: np.ones(n).T is

Matrix from outer product not positive definite

I was trying to simulate multivariate normal data in python the following way However, the resulting variables are always perfectly linearly correlated. I then checked np.linalg.eigvals(Sigma) and realized that Sigma is not positive semi-definite. This surprised me since 1) I did not get an error from multivariate_normal and 2) Sigma was generated from an outer product, which is supposed to

Advertisement