Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Random Numbers....
Author | Message | ||||
Phil23 Guru Joined: 27/03/2016 Location: AustraliaPosts: 1664 |
Can anyone point out the correct way to make sure the random number generator is NOT seeded for a test procedure on repeated runs. As in returning the SAME results each time. Reason..... 3 way challenge for the fastest "Lotto Draw" code, Finding 48 different numbers from a selection of 50..... As expected, the Teenager knows WAY more than his father.... Progress to date.... His runs faster with less lines of code... Main edge I have on him is that my returned list has no duplicate numbers... Lol. |
||||
CaptainBoing Guru Joined: 07/09/2016 Location: United KingdomPosts: 1985 |
Hey Phil23... hope you are good MX chips: The RND function is always seeded - it generates what look like random numbers procedurally - you can think of it as a great big list, you choose the entry point using RANDOMIZE. Each time you run your prog, unless you seed the list it will always give the same set of numbers (possibly defaults to zero as a result of the implicit clear in the RUN command). Sometimes it is useful to be able to generate the same set of "random" numbers. The usual trick is to use the timer to seed the list (RANDOMIZE TIMER) - it isn't truly random still but as the timer increments fairly quickly, the foibles of human reaction times (how long you take to start the prog so long as you never have a TIMER=... in your code) will usually add a degree of uncertainty (termed entropy). MZ chips: the RANDOMIZE function is gone in MMX MMBasic as it uses the built in random generator on the silicon. RND should always give you a good set of data for non-scientific/statistical purposes. On the subject of duplicates, they are a perfectly acceptable part of the nature of random just not in a closed set like the individually numbers balls in a lotto machine. This is a nice site for the discussion of random... hate to rain on your barby but there is a lottery picker on the site hope this helps |
||||
Print this page |