goodness of fit ksdensity

4 visualizaciones (últimos 30 días)
jstar
jstar el 20 de Oct. de 2020
Comentada: jstar el 5 de Nov. de 2020
Hi,
is there a way for testing the goodness of fit for ksdensity?
Thanks!

Respuestas (1)

Pratyush Roy
Pratyush Roy el 29 de Oct. de 2020
Hi jstar,
The goodnessOfFit function available in the System Identification Toolbox can be used to find goodness of fit.
Let us consider a set of random values on which we want to fit the kernel distribution. Here we are estimating our probability values on the same set of points which are being used to fit the distribution. For this we sort our x values in ascending order since their values are otherwise arbitrary.
rng('default') % For reproducibility
x = [randn(30,1); 5+randn(30,1)];
x_sort = sort(x);
[f,~] = ksdensity(x,x_sort);
Now the set of values in f can be compared against a set of reference values f_ref, using different cost functions like Mean Squared Error(MSE),Normalised Root Mean Squared Error(NRMSE) and Normalised Mean Squared Error(NMSE).
gof = goodnessOfFit(f,f_ref,'MSE') %3rd argument can be 'NRMSE' or 'NMSE',depends on the user.
Hope this helps!
Regards,
Pratyush.

Community Treasure Hunt

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

Start Hunting!

Translated by