1. ## Random Numbers testing

Hi All
Q) There is a one Text box and Push button labeled "OK". On clicking on the OK button random number is generated in the textbox. How you test this?

2. ## Re: Random Numbers testing

What is the length of random number? Does the length is constant or variable?

If the length is constant(ex:10 digit random number), you can always test for lenth.

3. ## Re: Random Numbers testing

One suggestion would be to run two different tests, first bring up the application and repeat the pushing of the OK box 10 times, save the results. Then do it again and make sure that none of the same numbers come up, this is basically making sure that they don't start with the same progression each time.

Next test would be to push the button 100,000 times or so, save each of the generated numbers in an list in the order in which they occurred, along with time information. After the test is complete, peruse the list and look for patterns, particularily ones correlated to the time information (it is often used to seed supposedly random number generators). If nothing is found, as a last test, sort the list from lowest number to highest number and graph the distribution and make sure that you have the proper distribution.

4. ## Re: Random Numbers testing

Hi MKrause,
Thanks for ur suggestion.
One more thing i would like to know from you that, can random numbers generated intially, are in between 0-1? irrespective of any language.
If so. Then we should have to contact developer for the logic he has used to generate the random numbers.

5. ## Re: Random Numbers testing

Mukund,

I don't know if I recall a random number generator that worked between 0 and 1. If I ran into that case, what I would probably do is determine how many digits of precision I required, if I required three digits of precision, I would then generate a random number between 0 and 1000, run that number into a string using sprintf, and then use another string function to place a decimal place three characters from the right hand side of the string and then turn it back into a float, of course this manipulation would only be required if I couldn't find a random float generator that worked between 0 and 1.

6. ## Re: Random Numbers testing

Yes, the basic random number function will return a result between 0 and 1, regardless of the programming language. In order to generate a number in the range [MIN_NUM, MAX_NUM], using the function RND(), you would use the formula:

NUM = (MAX_NUM * RND()) + MIN_NUM

7. ## Re: Random Numbers testing

PedroG,

I was thinking primarily of C, I believe that the rand funtion (stdlib.h) returns only integer values in that language, with the default being 32767 as the max value, with the max variable based on a define. That would seem to indicate that the above formula would not work in that case as only 0 and 1 would be the resultant values. Did I misunderstand your post when you indicated regardless of programming language?

8. ## Re: Random Numbers testing

MKrause,

No misunderstanding, I didn't know about the rand function. There appears to be more than one type of random number generator...

Of course I also found an error in the formula I listed. It should have been:

NUM = ((MAX_NUM - MIN_NUM + 1) * RND()) + MIN_NUM

as the first formula I gave would actually give you MAX_NUM possible values, starting at MIN_NUM, which isn't quite what you'd want (but do I get points for finding the bug in my own code?)

And you are correct, this formula won't work given the rand function in C.

9. ## Re: Random Numbers testing

I do not have an answer, but a question which may need to be addressed is, "how random are the random numbers?". If this random number generation is being used for any sort of security issue, it becomes quite relevant (if a hacker can figure out what random number algorithm is being used, he might be able to hack past this). Or if it is being used for something like a slot machine, it could result in a payout rate higher or lower than intended.

There are a number of papers out there on the web which discuss this. I am certainly not an expert on this subject, I just know that I have stumbled onto the periphery of related discussions in the past. Testing of such an issue would likely require very large numbers of test iterations and some fairly strong statistical analysis to determine how random your random numbers really are.

10. ## Re: Random Numbers testing

I'm not quite an expert in area, but I was very interested in this field (preudo random generators) many years ago.
There are several type of random generators,several of these being implemented in different languages,applications,... Usually this is a very well known information, so there are publi data about each type of this generator performances (like the lenght of the pseudo-random sequence, precision-number of bits,...), so I don't think it's something it should be tested (only if the developer used his own implementation of one of these algorithms).

The only thing which have to be tested is the initiation of the sequence (as it was already mentioned).

The most simple generator can be defined as:
X(n+1) = [X(n)*a+b] mod c
You can try to define your own RND- if you could find some appropiate values for a,b and c

About the minimum and maximum values: these generator are implemented to generate a binary sequence on 32/64/ bits. How evey language "translate" these values in decimal...
ususaly these are seen as values between 0 and 1, but also can be seen as values between 0 and 2^32-1 (for a 32 bit generator).

About encryption/security ,as far as I know, random number generator are not so used (are not considered very effective/efficient methods) or are used as auxiliary algorithms.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.