histogram2 versus mvnpdf

7 views (last 30 days)
Sylvia
Sylvia on 18 Feb 2020
Commented: Sylvia on 23 Feb 2020
I have two variables and would like to create a joint PDF. I am mainly interested in the shape of the PDF and not the actual probability. My variables are two column arrays: u and v. I first tried using histrogram2(u, v), but was unsure if that was the correct function to use. I then tried using the mvnpdf function to check. I tried JPDF = mvnpdf( [u ,v] ). I then plotted the result with scatter3(u,v,JPDF). I got a different shaped distribution curve than the histrogram2 curve. Can anyone explain why they would produce different shaped curves?

Accepted Answer

Raunak Gupta
Raunak Gupta on 21 Feb 2020
Hi,
The mvnpdf estimates the pdf value of each pair of variables with respect to zero mean and identity covariance matrix d-dimensional gaussian distribution where d is the number of variables. So, it uses the formula of multivariate normal distribution for calculation of those pdf values.
Whereas histogram2 just distributes the x and y variables as coordinates into the bins specified by the range of x and y variables and the number of bins.
So, the difference between the two is mvnpdf will give exact value according to multivariate normal distribution only while histogram2 will give the exact shape of the distribution based on the count of variables in specific range. For getting exact shape it requires data to be coming to all bins in histogram2 and there are enough instances of variable representing the distribution accurately.
  1 Comment
Sylvia
Sylvia on 23 Feb 2020
Thank you for the explanation, much appreciated

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!