home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 7749 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. X-Mailer: Mozilla 2.0 (X11; I; SunOS 5.5 sun4m)
  2. MIME-Version: 1.0
  3. Subject: Re: Randomness
  4. References: <451.6681T677T994@summat.demon.co.uk> <4l8ob9$22k@sinsen.sn.no>
  5. Content-Type: text/plain; charset=us-ascii
  6. Content-Transfer-Encoding: 7bit
  7. Path: imada.ou.dk!breese
  8. From: breese@imada.ou.dk (Bjorn Reese)
  9. Message-ID: <1996Apr21.134747.7212@imada.ou.dk>
  10. Sender: news@imada.ou.dk
  11. Nntp-Posting-Host: gounod.imada.ou.dk
  12. Organization: Dept. of Math. & Computer Science, Odense University, Denmark
  13. Date: Sun, 21 Apr 1996 13:47:47 GMT
  14. Newsgroups: comp.sys.amiga.programmer
  15.  
  16. Odd H. Sandvik wrote:
  17. > Check this out from P. Hanevold. Mind you, I haven't tried it.
  18. > From: patrick.hanevold@login.eunet.no (Patrick Hanevold)
  19. > ; By Patrick Hanevold 5/1-1996
  20.  
  21. > RND     MACRO
  22. >         move.w  (a0),\1
  23. >         move.w  2(a0,\1.l*2),\1
  24. >         move.w  \1,(a0)
  25. >         ENDM
  26.  
  27. The problem with this one is that it uses the old random number
  28. as an index for the next. This can lead to cycles.
  29.  
  30. Consider this: if the i'th number in the buffer contains the
  31. value i (if (rndbuf[i]==i)), it'll continue to return the value
  32. i forever. Making quick adjustments to avoid this problem doesn't
  33. work as the whole method is faulty.
  34.  
  35. I've previously made Patrick aware of this, but he didn't seem to
  36. care because it happend to work for him. That he ignores these
  37. flaws are ok by me, but when other people start using this method
  38. I feel that I have to warn about it. I'm not saying that this method
  39. doesn't work at all, just that there are some ugly traps in it, and
  40. sooner or later they _will_ occur.
  41.  
  42. Furthermore, this method suffers from the same problem as most
  43. simple/fast random number generators, namely that once you encounter
  44. a number twice it'll return the exactly same sequence of numbers again
  45. and again.
  46.  
  47. -- 
  48. Bjorn Reese                      Email: breese@imada.ou.dk
  49. Odense University, Denmark       URL:   http://www.imada.ou.dk/~breese
  50.  
  51. "It's getting late in the game to show any pride or shame" - Marillion
  52.