Filter löschen
Filter löschen

How to determine error between two distributions

7 Ansichten (letzte 30 Tage)
okoth ochola
okoth ochola am 13 Jun. 2023
Kommentiert: Paul am 13 Jun. 2023
Hello, I have the following code for comparing real and estimated distributions. The histogram represents the real while the curve is the estimated. How can I get the error (either the RMSE or R-squared) between the two curves. Any slight lead would be appreciated. As a far as am concerned its not possible to simply compare A and values obtained from wblpdf(sort(A),Overal_parameters(1),Overal_parameters(2)) since they're very different data types with different units. I suspect somehow we have to get probability distribution of the real data and compare it with the distribution obtain from wblpdf().
rng default
A=rnd(6000,1)
[Overal_parameters]= wblfit(A);
figure()
histogram(A,'Normalization','probability')
hold on
plot(sort(A),wblpdf(sort(A),Overal_parameters(1),Overal_parameters(2)))
legend('Observed Samples','Estimated Distribution')
xlabel('Mean wind speed (m/s)')
ylabel('Annual probabilty density')
hold off
  1 Kommentar
Paul
Paul am 13 Jun. 2023
The graphical comparison should use pdf normalization of the histogram.
Original code, but use use an actual Weibull distribution for the data
rng default
%A=rnd(6000,1);
A = wblrnd(4,3,6000,1);
[Overal_parameters]= wblfit(A)
Overal_parameters = 1×2
3.9904 3.0302
figure()
histogram(A,'Normalization','probability')
hold on
plot(sort(A),wblpdf(sort(A),Overal_parameters(1),Overal_parameters(2)))
legend('Observed Samples','Estimated Distribution')
xlabel('Mean wind speed (m/s)')
ylabel('Annual probabilty density')
hold off
Use pdf normalization to compare to the estimated pdf
figure()
histogram(A,'Normalization','pdf')
hold on
plot(sort(A),wblpdf(sort(A),Overal_parameters(1),Overal_parameters(2)))
legend('Observed Samples','Estimated Distribution')
xlabel('Mean wind speed (m/s)')
ylabel('Annual probabilty density')
hold off
I'm not sure what the goal is from here, but at least now the graphs comparable.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by