Area under distribution fit curve

조회 수: 8 (최근 30일)
See Kai Xiang
See Kai Xiang 2021년 9월 6일
답변: Star Strider 2021년 9월 6일
I used Statistics and Machine Learning add on to help me create a fit for my data. However, i now need to find the area under the fitted curve, and i am unable to use trapz(X,Y) since i do not have any variables and my data is a 261345x1 data set. Please advise!

채택된 답변

Star Strider
Star Strider 2021년 9월 6일
It would help to know the function used to fit the curve (for example nlinfit).
The nonlinear curve-fitting functions require that a model function be provided in order to estimate the parameters. That function can then be used with the integral function to find the area under the fitted curve, or to calculate the fitted values to use with trapz
t = linspace(0, 5);
s = t.^2 + randn(size(t));
fcn = @(b,x) b(1) .* x.^b(2);
B0 = rand(2,1);
B = nlinfit(t, s, fcn ,B0)
B = 2×1
0.9334 2.0407
AUC1 = integral(@(x)fcn(B,x), min(t), max(t)) % Use 'integral'
AUC1 = 40.9677
AUC2 = trapz(t, fcn(B,t)) % Use 'trapz'
AUC2 = 40.9699
figure
plot(t, s, '.')
hold on
plot(t, fcn(B,t), '-r')
hold off
grid
Experiment to get different results.
.

추가 답변 (1개)

KSSV
KSSV 2021년 9월 6일
Let Y be your 261345x1 data.
X = (1:length(Y))' ;
trapz(X,Y)

Community Treasure Hunt

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

Start Hunting!

Translated by