working with kolmogrov test
Afficher commentaires plus anciens
Hi, I am trying to use kolmogorov test which I' going to use it in my artickle , I generate a data set A then I randomly made a sample set from A. then I wanated to compare these two sample sets with kstest. but It showed me they don't have same distribution.
here is my simple code:
clc
clear all
close all
n_s = 1000;
mother_random_variable = lognrnd(0.3,0.5,[1,100000]); %data lognormal
S = mother_random_variable(randi(numel(mother_random_variable),1,n_s)) %sample
S_y = [S]'; %selected data
S_mean=mean(S_y); %mean sample
S_var=std(S_y); %variance sammple
test_cdf = [S_y,cdf('Lognormal',S_y,S_var,S_mean)]; %make cdf
kstest(S_y,'CDF',test_cdf) %ktest
plot(sort(S_y),logncdf(sort(S_y)),'r--')
hold on
cdfplot(S_y)
they have same distribution and ITs srange result . I found more strage result when I compare my data set with itself, Its result shows me they don't have same distribution.
clc
clear all
close all
n_s = 1000;
mother_random_variable = lognrnd(0.3,0.5,[1,100000]); %data
S=mother_random_variable; % I named data with S for simpler code
S_y = [S]'; %selected data
S_mean=mean(S_y);
S_var=std(S_y);
test_cdf = [S_y,cdf('Lognormal',S_y,S_var,S_mean)];
kstest(S_y,'CDF',test_cdf)
plot(sort(S_y),logncdf(sort(S_y)),'r--')
hold on
cdfplot(S_y)
DO you have any Idea. tanks
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Get Started with MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
