# Get the mean and standard deviation of the lower half of the first mode of a bimodal distribution

12 views (last 30 days)
Audun Kvalvaag on 2 Sep 2020
Commented: Image Analyst on 6 Sep 2020
Hi, I have a bimodal distribution (in the form of a vector) from which I want to fit a gaussian distribution to the lower half of the first mode and calculate the mean and standard deviation of that distribution.

Image Analyst on 4 Sep 2020
Here is code that uses fitnlm() to fit two Gaussians, and one that fits multiple Gaussians.
##### 2 CommentsShowHide 1 older comment
Image Analyst on 6 Sep 2020
Excel.ActiveWorkbook.Save;
Excel.Quit;
delete(Excel);
clear('Excel')
See attached utilities for Excel.

Abdolkarim Mohammadi on 2 Sep 2020
Edited: Abdolkarim Mohammadi on 2 Sep 2020
You can first determine the elements that are in the lower half
Then calculate the statistics
To fit a distribution, you can first collect the elements of the lower half
Then use the Curve Fitting App (type cftool in the command window).
Audun Kvalvaag on 4 Sep 2020
Thanks, I solved it by mirroring the lower half of the first mode with the flip function. I could then use this gaussian fit function: https://www.mathworks.com/matlabcentral/fileexchange/35122-gaussian-fit to get the mean and standard deviation.