Variance of a histogram in matlab my doubt is about a vector of values that I have and which histogram is the following one:



The function I used to create the histogram was:

histogram(q,1000); %q is the aforementioned vector of values


Now, I have to calculate the variance of each of the 2 gaussian distributions that appear in the image. I know that the function  var(x) gives you the variance of a vector, so I tried with:

h = hist(q,1000);
h1 = h(1:500);
h2 = h(500:1000);

v1 = var(h1); v2 = var(h2);


But it's obvious that the variance of each one will depend of the vector I use to calculate it. Another possibility is that knowing the mean of each distribution (-1 and 1 respectively), I could evaluate the pdf of a gaussian distribution in $f_x(\mu)$ and I would obtain that:

$$f_x(\mu) = \dfrac{1}{\sigma \sqrt{2\pi}}$$

However, the distributions aren't normalised and the normalisation of each distribution would depend again of the vector I chose.

I have no more ideas, so I hope someone can help me.

Thanks in advance for responding.
Your distribution is bi-modal and not Gaussian. I'm assuming you want to find the variance of each of the two modes (which look Gaussian by themselves).

In your case the modes don't seem to overlap, so the easiest way would to split this into positive and negative values

q1 = q(q &gt; 0);
q2 = q(q &lt; 0);
v1 = var(q1);
v2 = var(q2);