Random Distribution in Forth



1 EQU MASK

: RAND1+/- ( n -- n+1/-1 ) RAND MASK AND IF 1- ELSE 1+ THEN ;
: TEST-RAND { n - t - t }
0 -> t
0 n 0
?DO RAND1+/- DUP 0=
IF t 1+ -> t THEN
LOOP t
;

\ If RAND is linear
\ What is the function of n for the average value of t

jrh



.



Relevant Pages

  • Re: random number geneator
    ... > If you call rand(), it will also update the seed value. ... > generator to often, this statistical property cannot build up (as with ... >> because the loop has a constant relationship to clock. ... > the randomness of the sequence if you do it. ...
    (comp.lang.cpp)
  • Re: Need some more help in understanding how to use PostScript
    ... I'm updating the "program" I've written to use rand ... "randomly" in the 20 iterations I'll need for the loop. ... 0 moveto ... -144 rlineto ...
    (comp.lang.postscript)
  • Re: Please, comment my C code
    ... In that exercise, the author ... > mentioned that rand() function return values in the interval [0, ... > median and sometimes smaller. ... > write a program that calls rand, say 500 times, inside a for loop, ...
    (alt.comp.lang.learn.c-cpp)
  • Re: I need help on Number Based Repetition
    ... x = rand; ... You should initialize this total to zero before the loop. ... there's a slight possibility that you might ... Then calculate k/n and p outside the loop. ...
    (comp.soft-sys.matlab)
  • Re: error with " do while "
    ... Some languages which have a loop construct like DO WHILE ... The closest I can think of in Fortran is an infinite loop with EXIT. ...
    (comp.lang.fortran)