/* The Long Run Test[of Old FIPS 140-1] for 01 random sequence (full version required) */ /* Notice: This program does not work on Light version of GAUSS. */ new; cls; x=rndu(20000,1); x=(x.>0.5); /* x=rev(x); if you need the reverse order of it. */ call longrun(x); proc longrun(x); local c,count,n,i,maxrun; if ismiss(x); errorlog "Warning: missing data found."; x=packr(x); endif; if rows(x)<20000; errorlog "Error: This test requires the sample of at least 20000."; retp("."); endif; x=x[1:20000]; /* Use the first 20000. */ n=rows(x); c=miss(0,0); count=1; i=2; do while i<=n; if x[i-1]/=x[i] and i/=n; c=c|count; count=0; elseif x[i-1]/=x[i] and i==n; c=c|count|1; elseif x[i-1]==x[i] and i==n; count=count+1; c=c|count; endif; count=count+1; i=i+1; endo; c=c[2:rows(c)]; maxrun=maxc(c); print "The Long Run Test:"; print/lz "LongestRun=" maxrun;; if maxrun<34; print "Pass"; else; print "Fail"; endif; retp(maxrun); endp;