BBC BASIC
« Lottery numbers & non repeating values tool »
Welcome Guest. Please Login or Register. Mar 31st, 2018, 10:53pm
ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018. We apologize Conforums does not have any export functions to migrate data. Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.
Thank you Conforums members.
Cross-platform BBC BASIC (Windows, Linux x86, Mac OS-X, Android, iOS, Raspberry Pi)
Re: Lottery numbers & non repeating values tool
« Reply #10 on: Sep 2nd, 2017, 4:00pm »
Although I can't disagree with the logic behind "run time is unpredictable" - the lottery case here is a complete frippery. It's just a "throwaway" toy. Of course I wouldn't use the technique I did for anything approaching any seriousness but I stand by my choice for the lottery case because..
a) It's a complete frippery. b) The program is very short. c) We're only selecting ANY 7 numbers from 49 so there's no chance of this taking forever. d) The quality of the random numbers is irrelevant because any 7 will have an equal chance of winning.
I also ran some trials (a lot). The maximum number of lookup clashes in any single line was 6 - sounds a lot. However, in creating 10000 lottery lines a repeat lookup was necessary in 6.7% of cases - no problem.
Henceforward I will use the dates of my children's birthdays to derive (winning) lottery lines.
I stand by my choice for the lottery case because...
That's fine, with those qualifications. The trouble is that people may adapt the code for other applications without appreciating its limitations (for example they may come upon it years later as the result of a search).
My experience is that there is widespread misunderstanding about pseudo-random numbers and statistics, and although it's unlikely that anybody would use BBC BASIC for an online casino program, or something like that, it's not impossible.
Several years ago I wrote this article at the Wiki to draw attention to some of the pitfalls. It includes simple lottery draw and card shuffling programs. It's out of date to the extent that BBC BASIC no longer uses the value of TIME as a seed.
Re: Lottery numbers & non repeating values tool
« Reply #12 on: Sep 2nd, 2017, 9:00pm »
Thanks for that link Richard - very good article. Although I'm gradually working my way through the info in the wiki, I admit I haven't read that one before. Everybody who uses BB4W should go and rummage through the wiki - there's so much excellent information in there.
I use CryptGenrandom a lot for 'professional' use. I think I posted something here that used it a short time ago - but I don't remember what right now. (My memory ain't what it used to be).