|
QSA ToolWorks Public Feedback Forum forum home | register | profile | members |search | faq homepage | lost password? | chat room |
| QSA ToolWorks Public Feedback Forum > General Helix Talk > random | You are not logged in. Login or Register. |
| Pages: 1 |
| Author: | Topic: random | |||
| mithlogy Member Posts: Registered: |
One of the things I'd like to do is to be able to select a random record. Until the team gives us a RANDOM tile, does anyone have a good way to pick a random record? This would be especially useful in developing onscreen quizzes that would automatically generate themselves by randomly selecting distractor items, for example. I would appreciate any ideas. |
|||
| chuckbo Posts: 42 Registered: 2003-04-09 |
I have a trick that I use to generate random numbers. Start with a seed between 0 and 1. Add that number to pi and raise it to the power of 5. Take the fractional part of that. 1) multiply this value by your largest number, take the integer, and add 1. 2) this value becomes the next seed. This is a routine that came from an old HP-25 programming book. chuck |
|||
| JeffNY Posts: 67 Registered: 2003-05-23 |
Could he also use the date/time as a source for a seed value?
|
|||
| chuckbo Posts: 42 Registered: 2003-04-09 |
Yes. The advantage of providing your own seed value is that you can replicate the stream of numbers in testing. Now that I try to recall, I think that I take the number of seconds since some day, divide it by 1000000 and add it to the number, also, before raising it to the power of 5. I didn't have to do that on my HP calculator or in BASIC (or even when I did it in Helix years ago), but I just recently felt that a flashcard database was recycling too quickly, so I added this extra bit of randomness. chuck |
| Pages: 1 |
| Lost Password? Powered by UPB Version : 1.8 A script by PHP Outburst |