Hướng dẫn plot multivariate gaussian python
I think this is indeed not very friendly. I will write here the code and explain why it works. The equation of a multivariate gaussian is as follows: In the 2D case, and are 2D column vectors, So in the 2D case, the vector is actually a point (x,y), for which we want to compute function value, given the 2D mean vector , which we can also write as (mX, mY), and the covariance matrix .To make it more friendly to implement, let's compute the result of :So (CI[0,0] * (x - mX) + CI[1,0] * (y - mY) , CI[0,1] * (x - mX) + CI[1,1] * (y - mY)), where CI is the inverse of the covariance matrix, shown in the equation as , which is a 2x2 matrix, like is.Then, the current result, which is a 2D row vector, is multiplied (inner product) by the column vector CI[0,0](x - mX)^2 + (CI[1,0] + CI[0,1])(y - mY)(x - mX) + CI[1,1](y - mY)^2 This is going to be easier to implement this expression using NumPy, in comparison to , even though they have the same value.
The result: This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
|