Covariance Matrix

I Dont get where’s the issue??

1 Like

The issue is that your get_cov_matrix() function doesn’t give the correct results for one of the tests that is used by the test_cov_matrix() function.

1 Like

Yeah, it’s your values. If the previous test – centering your data – passed, then the issue will be with the calculation of the covariance matrix. I did it in two steps, which seems to be how the code is laid out:

{mentor edit: code removed}


@Sean_Olson, please do not post the code for the programming assignments. That’s not allowed by the Code of Conduct.

the previous test passed successfully, and the math for the calculation of the covariance is correct, thanks will check

1 Like

@Sean_Olson, it’s trivially different from the solution. Please don’t.

Just an update, I could resolve the issue but I dont get what the difference btwn np.divide and ‘/’

np.divide takes two array-like arguments, and returns an ndarray.
It will do some automatic broadcasting if the two arguments are different shapes.

The ‘/’ operator depends on whether you have some package installed that
overrides the regular python ‘/’. It also depends a bit on what version of Python you’re using. Some will do different things if you use ‘/’ with integers.

If both arguments are ndarrays, then ‘/’ will be implemented as np.divide().

1 Like