How do I fit the Gaussian distribution?

조회 수: 32 (최근 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개)

카테고리

Help CenterFile Exchange에서 Exploration and Visualization에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by