Fitting Cumulative Normal Distribution Function to Data
이전 댓글 표시
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
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
2021년 12월 22일
Hello,I want to make a cumulative chi-square distribution fitting data. How do I rewrite the program? After I rewrite it, it has been unable to fit.
linlin
2021년 12월 22일
May I ask the first half of the fitting effect is not very good, what measures should be taken?
Star Strider
2021년 12월 22일
It is apparently not the correct distribution for those data.
linlin
2021년 12월 23일
Then how should I fit it, thank you
linlin
2021년 12월 23일
I just started to learn this and I still don’t understand, can you help me, thank you
linlin
2021년 12월 23일
X = [38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64];
Y = [0 0.02 0.02 0.03 0.04 0.04 0.05 0.05 0.07 0.08 0.08 0.08 0.1 0.11 0.14 0.17 0.19 0.2 0.25 0.44 0.51 0.6 0.67 0.78 0.87 0.96 1];
The data I want to fit is this.
linlin
2021년 12월 23일
When x is less than 38, y is all 0; when x is greater than 64, y is all 1. So it should obey the cdf distribution
Star Strider
2021년 12월 23일
linlin
2021년 12월 24일
I don't understand, can you tell me more specifically. Scientific research novice, trouble
linlin
2021년 12월 24일
And my data is CDF, not PDF
linlin
2021년 12월 24일
This seems to be a worse fit, please give pointers, thank you
linlin
2022년 1월 10일
Can you give me some pointers?
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
카테고리
도움말 센터 및 File Exchange에서 Exploration and Visualization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!