# 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.

• you have a bimodel distribution.
– user28715
Nov 2, 2018 at 14:01

q1 = q(q > 0);