function xlotto(picks, X) % xkeno(picks, X) plays keno with the 20 state-chosen good numbers in % the row vector picks, and the keno type random variable X. For good % results, X should be generated like this: X=rvperm(60, 10, N, seed). % If the picks vector is empty, the good numbers will be generated % randomly. if ~(length(picks)==20 | length(picks)==0) error('must pick 20 numbers') end if picks==[] picks=rvperm(60, 20, 1, sum(100*clock)); disp('State picked numbers:'); s=''; for i=1:20, s=sprintf('%s %d', s, picks(i)); end disp(s); else for i=1:6, if picks(i)<1 | picks(i)>60 error('numbers are between 1 and 60') end for j=i+1:6 if picks(i)==picks(j) error('numbers may be picked only once') end end end end s=size(X); if ~(s(2)==10) error('invalid random variable matrix') end matched=zeros(1,11); for trial=1:s(1), match=0; for j=1:10, for i=1:20, if X(trial, j)==picks(i) match=match+1; end end end matched(match+1)=matched(match+1)+1; end for i=1:11, S=sprintf('Matched %d numbers %2d times: %f predict %f', i-1, matched(i), matched(i)/s(1), hypergeo(60, 20, 10, i-1)/cmb(60,10)); disp(S) end