How do I fit the Gaussian distribution?

52 ビュー (過去 30 日間)
studentmatlaber
studentmatlaber 2021 年 9 月 14 日
コメント済み: Star Strider 2021 年 9 月 22 日
The noise histogram is a Gaussian distribution as seen in the graph. I want to fit this histogram. I used 'histfit' command but it didn't give correct result. So I wrote code to manually fit it. However, as you can see, this does not give the correct result. How do I fit this histogram correctly? I would be very happy if you could help me with this subject.
noise_filt = cat(2,filt_noise{:});
mu = 0; %mean
noise_sigma = 29*10^-6; %std deviation
noise_varyans = noise_sigma^2;
x = -0.1:0.001:0.1;
pdf = (1/sqrt(2*pi*noise_sigma^2)) .* exp((-(x-mu).^2)/(2*noise_sigma^2));
histogram(noise_filt);
%histfit(noise_filt);
hold on;
plot(x,pdf,'LineWidth',2);
Undefined variable filt_noise.

採用された回答

Star Strider
Star Strider 2021 年 9 月 14 日
It gave a much better result when I ran it (R2021a) —
LD = load('noise_filt.mat');
noise_filt = LD.noise_filt;
figure
hhf = histfit(noise_filt)
df = fitdist(noise_filt(:), 'Normal')
df =
NormalDistribution
Normal distribution
mu = 3.27713e-05 [9.07426e-06, 5.64683e-05]
sigma = 0.00865728 [0.00864056, 0.00867407]
It won’t be exact unless it has a ‘perfect’ normal distribution. That’s likely as good as it gets.
.
  8 件のコメント
studentmatlaber
studentmatlaber 2021 年 9 月 22 日
I manually fit in the weibull distribution. I didn't use the histfit command. That's why I couldn't find a solution in the mse account. If you know any other way, please tell me, I'm so desperate. I created a question for Gaussian. https://uk.mathworks.com/matlabcentral/answers/1458414-how-to-calculate-mse-for-gaussian-histogram
Star Strider
Star Strider 2021 年 9 月 22 日
The histfit function should work with the Weibull distribution, and wblfit should work to estimate the parameters and confidence intervals on them. Getting the ‘typical’ statistics that relate to a nonlinear fit with respect to a histogram and a specific distribution may not be the correct approach.
The distribution fitting functions (using the maximum likelihood estimate) fit the parameters of the distribution, not the histogram. Ths histogram is simply provided in order to understand the nature of the fitted distribution and how it relates to the data. The mlecov function can provide a covariance matrix on the parameters.
I’m sort of lost here. I thought we already solved this problem with the nonlinear fit to the histogram.
.

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by