How can I separate a bimodal distribution into two normal distributions?

34 views (last 30 days)
Hi, I have a data that once plotted in a histogram shows a bimodal distribution.
bimodal distrib.jpg
I would like to separate the bimodal distribution into two normal distributions with respective means and standard deviation. Is there a way to individually fit the distribution to obtain the respective parameters (mean and standard deviation)? Other ways are also welcome to suggest.
Thank you all.
  2 Comments
Wei
Wei on 12 Feb 2020
I also have this problem, Please get answer to teach me, thank you very much
Umar
Umar on 28 Jul 2024

Hi @Lazuardi Pujilaksono ,

To separate a bimodal distribution into two normal distributions and estimate their parameters (mean and standard deviation) individually, I will use a mixture model approach assuming that the bimodal distribution is a mixture of two normal distributions. Here is the code snippet that illustrates that,

data = [randn(1000,1) + 2; randn(1000,1) + 5]; % Creating a bimodal distribution

gm = fitgmdist(data, 2); % Fit a Gaussian mixture model with 2 components

mu = gm.mu; % Means of the two normal distributions

sigma = sqrt(gm.Sigma); % Standard deviations of the two normal distributions

x = linspace(min(data), max(data), 1000);

pdf1 = normpdf(x, mu(1), sigma(1));

pdf2 = normpdf(x, mu(2), sigma(2));

figure;

histogram(data, 'Normalization', 'pdf');

hold on;

plot(x, pdf1, 'r', 'LineWidth', 2);

plot(x, pdf2, 'b', 'LineWidth', 2);

legend('Data', 'Normal Distribution 1', 'Normal Distribution 2');

xlabel('Value');

ylabel('Probability Density');

title('Separated Normal Distributions from Bimodal Distribution');

Please see attached plot.

Hope this answers your question.

Sign in to comment.

Answers (1)

Jeff Miller
Jeff Miller on 3 May 2019
GMModel = fitgmdist(x,2); % Your data are in x

Community Treasure Hunt

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

Start Hunting!