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.
y = cdf('Lognormal', S_y, S_var, S_mean); % your code, incorrect y = cdf('Lognormal', S_y, S_mean, S_var); % correct
2) This is just a suggestion but it's a bit cleaner to use the makedist() function rather than entering the parameters manually into cdf().
doc cdf pd = makedist('Lognormal', 'mu', S_mean, 'sigma', S_var); y = cdf(pd, S_y); % instead of cdf('Lognormal', S_y, S_mean, S_var)
3) " when I compare my data set with itself, Its result shows me they don't have same distribution." But you aren't comparing your data with itself. You're comparing your data with the results of the cumulative distribution function of your data. The plot below shows the distribution of values from your data (top) and the distribution of values from the CDF. Clearly those distributions differ and the kstest() correctly rejects the null hypothesis.
figure subplot(2,1,1) histogram(S_y) title('mother random variable') subplot(2,1,2) histogram(cdf('Lognormal', S_y, S_mean, S_var)) title('CDF distribution')
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.