MATLAB Answers

How to fit a multi modal distribution using a weighted sum of PDFs?

18 ビュー (過去 30 日間)
Maria Amr
Maria Amr 2021 年 3 月 2 日
コメント済み: Maria Amr 2021 年 4 月 6 日
I am new to matlab and I know my question is rudimentary. I really appreciated if you help me. I have a data-set (attached) shows multi modal distributions and I want to make a fit using a weighted sum of PDFs. How may I do that?
I have applied the Kernel distribution but I am not sure is right.
clear all;
close all;
hold on
[f,x11] = ksdensity(rr,'Bandwidth',0.0028);
  1 件のコメント
Maria Amr
Maria Amr 2021 年 3 月 2 日
Bjorn Gustavsson Perfect! Really appreciated!



Bjorn Gustavsson
Bjorn Gustavsson 2021 年 3 月 2 日
編集済み: Bjorn Gustavsson 2021 年 3 月 2 日
You don't have enough samples to confidently claim you have a multimodal distribution. If you simply try this with fitting exponential distributions to your data you'll see that they work reasonably OK:
PARHAT = expfit(abs(rr));
PARHATp = expfit(rr(rr>=0));
PARHATm = expfit(-rr(rr<=0));
hold on
x = linspace(-0.1,0.1,1001);
There are indications that there might be a multimodal distribution, but if you do fit for a multimodal distribution you will probably find that the parameter uncertainty will be very large. First you need to gather more observations (hopefully this will be possible without too large costs in time and resources).
  6 件のコメント
Maria Amr
Maria Amr 2021 年 4 月 6 日
Bjorn Gustavsson, You have already provided me a great answer that is working very well. Now I need to compare the previous result with a case with a few modes. You have already mentioned the data is not enough to claim a multimodal distribution. I truly appreciate you to direct me how I can show a multimodal dataset assuming the samples are enough. I means I want to show a data set like the attached figure (the figure is not mine and I only use it to express my question). The dataset is the same already attached above.Thank you in advance!


その他の回答 (1 件)

Tom Lane
Tom Lane 2021 年 3 月 2 日
I'm glad Bjorn provided an answer that works for you. For future reference, there is a function for fitting mixtures of normal distributions:
Also, there is an example that fits a mixture of two normals, but it can be adapted to fix mixtures of any distributions:
  3 件のコメント
Tom Lane
Tom Lane 2021 年 3 月 3 日
@Maria Amr, I don't know what h() is in your code, but if it is a variable then you are indexing into it using values like -0.1.


Community Treasure Hunt

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

Start Hunting!

Translated by