% ranksum test for two independent samples
% example on page 678 of the textbook
x=[-3.10, 1.67, 2.01];
y=[5.27, 1.89, 3.86, 0.19];
[p, h, stats]=ranksum(x,y);
% Note: "p" is the two-sided p-value
% signtest for paired samples
data=load('children.dat');
x=data(:,1);
y=data(:,2);
y-x
[p, h, stats]=signtest(x,y);
% Goodness-of-fit test
% Benford's Law
k=1:9;
freq = log10(1+1./k);
bar(freq);
% data: 355 first digits appearing in the 1997-98 operating
% budget for the Univ of West Florida
data=load('budget.dat');
O=data(:,2);
sum(O)
E=sum(O)*freq';
chi2 = sum((O-E).^2./E)
1-chi2cdf(chi2,9-1)