X = load('./data/islands.csv'); Y = log(X); n= length(Y); breaks = 2:10; counts = histc(Y, breaks); hist(Y, 2.5:9.5); % this produces a desired histogram cumul = cumsum(counts); normQ = norminv( cumul/(n+1),0,1); % standard normal quantiles figure(2) plot(breaks, normQ, '*'); % QQ plot based on "breaks" normplot(Y) % biult-in Matlab function. Has the same shape, but the Y-axis is labeled differently qqplot(Y) % another option, with axes switched % ----------------------------------- %% QQplot of Ca + Mg, based on quantiles % X = load('./data/camg1.csv'); ca020 = X(:,5); mg020 = X(:,6); scatter(ca020, mg020) decile1 = prctile(ca020, 0.1:0.1:0.9); decile2 = prctile(mg020, 0.1:0.1:0.9); plot(decile1, decile2,'*') % Kolmogorov-Smirnov test % muhat = mean(Y); sdhat = std(Y); Ysort = sort(Y); CDFfit = [Ysort normcdf(Ysort,muhat, sdhat)]; [h, pvalue ,D, crit] = kstest(Y,CDFfit) % KS test compares the emprical CDF of data Y to the suggested % CDFfit. % see Matlab help for a detailed explanation cdfplot(Y) hold on xc = 2:0.2:10; plot(xc, normcdf(xc,muhat, sdhat), 'red'); hold off