How to fit a cumulative normal distribution into a smooth curve?

조회 수: 20 (최근 30일)
Rohit Sinha
Rohit Sinha 2022년 6월 8일
댓글: Sam Chak 2022년 6월 8일
I have computed the normal cumulative distribution values for a certain set of data. The data is as follows:
x = [0.005 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4];
prob = [0.0000 0.0000 0.0000 0.0000 0.0000 0.0002 0.0007 0.0018 0.0041 0.0080 0.0138 0.2011 0.4663 0.6518 0.8110 0.9028 0.9470 0.9728 0.9851 0.9920 0.9963 0.9975 0.9983 0.9990];
where prob contains the probability of failure at corresponding value of x already obtained using normcdf on the reliability index.
I want to make a smooth CDF using this data (prob vs x) by passing this data to a function. How do I do it?
I've already used a function available at https://in.mathworks.com/matlabcentral/answers/345595-fitting-cumulative-normal-distribution-function-to-data but using this is leading to a problem that even though the first probability values are zero, the fit does not start from zero. I'm in need of something similar

채택된 답변

Sam Chak
Sam Chak 2022년 6월 8일
편집: Sam Chak 2022년 6월 8일
The Error function is essentially identical to the standard normal cumulative distribution function, and so I attempted to fit the Error function to the data, with the aim to connect as many points as possible.
myfittype = fittype('0.5*erf(6.6*(x - c)) + 0.5',...
'dependent', {'prob'}, 'independent', {'x'},...
'coefficients', {'c'})
[myfit, gof] = fit(x', prob', myfittype)
which produces
myfit =
General model:
myfit(x) = 0.5*erf(6.6*(x - c)) + 0.5
Coefficients (with 95% confidence bounds):
c = 0.3302 (0.3111, 0.3493)
gof =
struct with fields:
sse: 0.0520
rsquare: 0.9895
dfe: 23
adjrsquare: 0.9895
rmse: 0.0476
plot(myfit, x, prob)
  댓글 수: 6
Rohit Sinha
Rohit Sinha 2022년 6월 8일
편집: Rohit Sinha 2022년 6월 8일
@Sam Chak, yes, all my data is bounded between 0 and 1. However, 0.5*erf(b*(x - c)) + 0.5 results in the line take an offset from 0. That means, the fit does not start from 0 but a significant (visible) distance above it. Hoever I believe, as you say, playing with the value of 'b' must do the trick. Thanks a lot
Sam Chak
Sam Chak 2022년 6월 8일
@Rohit Sinha, I have not seen all your data. And I hope you understand that the CDF (aka biased Error function) only achieves true 0 at .
By manipulating the b value, you can practically shape the curve you want to fit as many data points as possible.
You will need some time to explore which CDF/Error function model fits the data set. If my Answer solves your original problem and you gain something useful and knowledge from my Comments, please support by voting and accept it.
We can still continue with the discussion, if you are still interested to fit all 6 data sets.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by