       10 // Random number test program
       20 //
       30 tester(100000, 10)
       40 tester(100000, 19)
       50 tester(100000, 1)
       60 tester(100000, 20)
       70 PRINT "Ok"
       80 //
       90 PROC tester(samples#, hi#) CLOSED
      100   expected:=samples#/(hi#+1)
      110   DIM a#(0:hi#)
      120   FOR f#:=1 TO samples# DO
      130     n#:=RND(hi#)
      140     a#(n#):+1
      150   ENDFOR f#
      160   //
      170   sum:=0; tot#:=0
      180   //
      190   FOR f#:=0 TO hi# DO
      200     diff:=a#(f#)-expected
      210     tot#:+a#(f#)
      220     sum:+diff
      230     SYS assert, ABS(diff)<expected/20
      240   ENDFOR f#
      250   //
      260   SYS assert, tot#=samples# AND ABS(sum)<0.000001
      270 ENDPROC tester
