Skip to content

Tag: numpy

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 multiva…

Alternating column values

I am working on a project where my dataset looks like bellow: Origin Destination Num_Trips Hamburg Frankfurt 2 Hamburg Cologne 1 Cologne Hamburg 3 Frankfurt Hamburg 5 I am interested only on one way either “Hamburg – Frankfurt” or “Frankfurt – Hamburg” and add them as numbe…

the speed of numpy sum of different axis

We know that numpy is C order stored so .sum(axis=1) should be faster that .sum(axis=0). But I find that But when the size change to 10000 Answer First of all, I cannot reproduce the effect with the last version of Numpy (dev) nor the version 1.21.5. I got respectively 30.5 ms and 36.5 ms (so the opposite beh…