Plotting a function with two terms or alternatively a curve of best fit to a histogram
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello,
I have a data set (H) that I have plotted on a histogram (Hist). The histogram displays a bimodal distribution.
The histogram includes some negative values on the x-axis. The values for the y-axis are not from data I have in my workspace but instead the frequency of my x-vales that was calculated by the histogram function.
I would like to fit a curve to this histogram that has the function :
f = @(A,m,s,H) A(S) * exp(-((H-m(S))/s(S)).^2) + A(S2) * exp(-((H-m(S2))/s(S2)).^2)
Alternatively, any solution that would allow me to fit a curve of best fit to this data would amazing.
I have trawlled all the forums but haven't found a solution that works.
Any help would be greatly appriciated.
댓글 수: 5
Torsten
2020년 4월 2일
편집: Torsten
2020년 4월 2일
You can't use curve fitting for this kind of problem since the fitting parameters will strongly depend on the bin width.
Although it might be hard statistics for a beginner, you should read about maximum likelihood estimation and use Matlab's "mle" or the tools for which "the cyclist" provided links.
Wikipedia's article about "Probability distribution fitting" is a good starting point.
답변 (1개)
the cyclist
2020년 3월 31일
If you have all of the x values, then you should be able to fit using the fitgmdist function, which will find the best fit to multiple gaussians. You won't need to specify your function.
If you have only the bin locations and counts, then you should be able to use the fitnlm function. You will need to specify your function in this case.
Both of these functions are from the Statistics and Machine Learning Toolbox.
참고 항목
카테고리
Help Center 및 File Exchange에서 Histograms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!