How can I compute the standard deviation of a Gaussian fit generated with the Curve Fitting App?

조회 수: 39 (최근 30일)
I have some data that I have binned with the hist function.  I am trying to fit a Gaussian function to the histogram data, and I noticed that the parameter c1 of the Gaussian fit in the Curve Fitting App does not correspond to the standard deviation of a Gaussian distribution.  I exported my fit and tried calling std on the fit object, but I get the error
 
Undefined function 'sum' for input arguments of type 'cfit'.
Error in var (line 85)
        xbar = sum(x, dim) ./ n;
Error in std (line 31)
y = sqrt(var(varargin{:})); 
How can I display the standard deviation of the fit?

채택된 답변

MathWorks Support Team
MathWorks Support Team 2022년 5월 13일
편집: MathWorks Support Team 2021년 2월 25일
The pre-defined Gaussian fitting function in the Curve Fitting App is defined slightly differently than the probability distribution function of a Gaussian random variable.  Since the "Results" pane in the Curve Fitting App only displays the values of the model parameters, it is not possible to have the App display the standard deviation of the Gaussian function as it is typically defined.  Moreover, the std function is not defined for cfit objects since this has no logical meaning for most models, so calling std on the exported model yields an error.
As a workaround, you can define a Custom Equation as the model type and supply the statistical definition of a Gaussian function, using the standard deviation as its own parameter.  The fit will then display the value of the standard deviation in the "Results" pane.
Alternatively, instead of fitting a Gaussian function to the histogram data, you can use the
directly on the original data.  This will allow you to fit a Normal distribution to the data and will display its mean and variance.  You can then export the distribution to the workspace and call the std function on the distribution.  This will return the standard deviation of the fitted probability distribution.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Fit Postprocessing에 대해 자세히 알아보기

제품


릴리스

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by