(12C) Two Random Generator Comparison

07252018, 10:47 AM
(This post was last modified: 07262018 02:04 PM by Gamo.)
Post: #1




(12C) Two Random Generator Comparison
This program compare the two "Random Number Generator" by the use of "Accumulate Statistic"
Then get the " Average" result from both random generator. 1st Random Generator used: e^(X+Pi) FRAC 2nd Random Generator used: (X*997) FRAC Second Generator used the result from the First generator as a seed. Both generate 6 Digits Random Number then store [Σ+] Program use the Counter to provide the amount of count to generate. Remark: I noticed that there many discussion about Random Generator in this forum. This program is a rough comparison only and by mean of the use of the Statistic Average. The result average I mostly see is around 450,000 to 550,000 range. So this program is good for observation to see the many different result depending on specific count. See for yourself !!! Example: Clear [Σ] // must clear statistic register for any new start Example below will give different result each time. First try small count. Let's try 100 times 100 [R/S] Display briefly show 0,00000000 indicate that almost done 506,951 // 2nd Average Random result [X<>Y] 485,063 // 1st Average Random result 5000 [R/S] Display briefly show 0,000000000 499,077 // 2nd Average Random result [X<>Y] 507,235 // 1st Average Random result For very large count it is best to use the 12C+ or Emulator. I have try one million count and took about 34 minute on Android 12C app Program: Compare two Random Generator Code:


07252018, 12:15 PM
Post: #2




RE: (12C) Two Random Generator Comparison
Speed suggestion: Since we're only interested in the average, adding the random numbers on the stack and dividing by the loop count would run much faster than using the Σ+ function which does a lot more than sum the X's.
<0ɸ0> Joe 

07262018, 12:07 AM
Post: #3




RE: (12C) Two Random Generator Comparison
Thanks Joe
I'll make an update soon. Gamo 

07262018, 10:48 AM
(This post was last modified: 07262018 10:54 AM by Gamo.)
Post: #4




RE: (12C) Two Random Generator Comparison
Here is the updated version without the use of the Statistic Register.
Procedure to run this program is the same as above. Don't forget to clear REG each time for a new run. Program: Compare Two Random Number Generator Code:
Gamo 

07262018, 06:03 PM
(This post was last modified: 07262018 06:47 PM by Dieter.)
Post: #5




RE: (12C) Two Random Generator Comparison
(07252018 10:47 AM)Gamo Wrote: This program compare the two "Random Number Generator" by using the "Accumulate Statistic" Gamo: sorry, but this does not work. You cannot use the result of one RNG as the input of another one as this does not return what the second RNG should. Instead you actually get the results of a third, different RNG which here in this case is \(\large x_{n+1} = frac(997 \cdot frac(e^{x_n+\pi})) \) (Well, not quite, as the result is not the input of the first RNG again) Also the mean does not say much about a RNG. Consider a RNG that returns 0,5 0,5 0,5 0,5 0,5... or 0,4 0,6 0,4 0,6... All this gives a perfect 0,5 as the mean. Although the sequence sure is not random at all. The following program is different from yours in these points:
Code: 01 STO 0 Example: 0,1234567 [STO] 7 [STO] 8 1000 [R/S] ... 0 g [\(\bar{x}\)] => 0,4855 [X<>Y] 0,5002 g [\(s\)] => 0,2898 [X<>Y] 0,2888 Of course the \(\bar{x}\) and \(s\) calculation could also be done by the program, but when the user invokes these functions he always knows which value he gets. And it doesn't require more than pressing a key. Dieter __________ * Yes, the calculated (sample) standard deviation actually is slightly less by a factor of sqrt((n–1)/n) but for large sample sizes this does not make much of a difference. 

07272018, 07:27 AM
Post: #6




RE: (12C) Two Random Generator Comparison
(07262018 06:03 PM)Dieter Wrote: * Yes, the calculated (sample) standard deviation actually is slightly less by a factor of sqrt((n–1)/n) but for large sample sizes this does not make much of a difference. Or then you just add the mean before calculating the standard deviation:


07272018, 11:42 AM
(This post was last modified: 07272018 12:15 PM by Dieter.)
Post: #7




RE: (12C) Two Random Generator Comparison
(07272018 07:27 AM)Thomas Klemm Wrote:(07262018 06:03 PM)Dieter Wrote: * Yes, the calculated (sample) standard deviation actually is slightly less by a factor of sqrt((n–1)/n) but for large sample sizes this does not make much of a difference. That's a good idea. This also leaves the mean unaffected so that both [\(\bar{x}\)] and [\(s\)] return the desired results, i.e. mean and population standard deviation. To implement this idea simply replace line 21 (GTO 00) with GTO 37 and add this: Code: 37 xbar This way the example with seed = 0,1234567 returns g [\(\bar{x}\)] => 0,4855 [X<>Y] 0,5002 g [\(s\)] => 0,2897 [X<>Y] 0,2886 So for this seed (!) the second RNG almost perfectly matches the theoretical values. Also these results are not very different from the original ones with the sample standard deviation. Rule of thumb: For 10^{n} random numbers the results agree in n decimals. In this case, with 10³ numbers, in the first three (0,290 and 0,289). Dieter 

« Next Oldest  Next Newest »

User(s) browsing this thread: 4 Guest(s)