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

enter image description here

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.

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

1 Answer 1


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 > 0);
q2 = q(q < 0);
v1 = var(q1);
v2 = var(q2);
  • $\begingroup$ Thanks for the correction, but if for example I choose: q1 = q(q > 0.5); q2 = q(q < 0.5); v1 = var(q1); v2 = var(q2); Wouldn't the variance change remaining q1 and q2 as guassians? $\endgroup$
    – Josemi
    Nov 2, 2018 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.