function xlotto(picks, X) % xlotto(picks, X) plays lotto with the 6 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(42, 6, M, seed). % If the picks vector is empty, the good numbers will be generated % randomly. if ~(length(picks)==6 | length(picks)==0) error('must pick 6 numbers') end if picks==[] picks=rvperm(42, 6, 1, sum(100*clock)); disp('State picked numbers:'); s=''; for i=1:6, s=sprintf('%s %d', s, picks(i)); end disp(s); else for i=1:6, if picks(i)<1 | picks(i)>42 error('numbers are between 1 and 42') 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)==6) error('invalid random variable matrix') end matched=zeros(1,7); for trial=1:s(1), match=0; for j=1:6, for i=1:6, if X(trial, j)==picks(i) match=match+1; end end end matched(match+1)=matched(match+1)+1; end for i=1:7, S=sprintf('Matched %d numbers %2d times: %f predict %f', i-1, matched(i), matched(i)/s(1), hypergeo(42, 6, 6, i-1)/cmb(42,6)); disp(S) end