Fitting Cumulative Normal Distribution Function to Data

6 ビュー (過去 30 日間)
Jake
Jake 2017 年 6 月 20 日
コメント済み: Rohit Sinha 2022 年 6 月 8 日
Hello, I have the following data and would like to fit a cumulative normal distribution to it.
X = [-75, -50, -17, -9, 11, 25, 43, 67]; Y = [5, 0, 25, 25, 65, 80, 70, 75];
By dividing by 100, these values can be normalized such that X goes from -1 to 1 and Y goes from 0 to 1.
I'd like to fit this data so that the error is minimized between my recorded Y values and the values of an appropriate cumulative normal distribution function. How can I determine the values for Mu and Sigma? I tried using normfit, but that only used my X values and nothing changed when my data changed.
I'd also like to get an R-squared metric for the goodness of fit if possible.
Thanks in advance, Jake

回答 (1 件)

Star Strider
Star Strider 2017 年 6 月 20 日
This seems to work:
X = [-75, -50, -17, -9, 11, 25, 43, 67];
Y = [5, 0, 25, 25, 65, 80, 70, 75];
fcn = @(b,x) normcdf(x, b(1), b(2)); % Objective Function
NRCF = @(b) norm(Y/100 - fcn(b,X)); % Norm Residual Cost Function
B = fminsearch(NRCF, [0; 10]); % Estimate Parameters
Xplot = linspace(min(X), max(X));
figure(1)
plot(X, Y/100, 'pg')
hold on
plot(Xplot, fcn(B,Xplot))
hold off
grid
text(-50, 0.65, sprintf('\\mu = %.1f\n\\sigma = %.1f', B))
  13 件のコメント
linlin
linlin 2022 年 1 月 10 日
Can you give me some pointers?
Rohit Sinha
Rohit Sinha 2022 年 6 月 8 日
@Star Strider I tried using your function, however, the starting values of probability even though are zero, or approximately zero, there is a slight difference in the initial point of the fitted curve as shown

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

Community Treasure Hunt

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

Start Hunting!

Translated by