Post Reply 
(12C) Two Random Generator Comparison
07-26-2018, 06:03 PM (This post was last modified: 07-26-2018 06:47 PM by Dieter.)
Post: #5
RE: (12C) Two Random Generator Comparison
(07-25-2018 10:47 AM)Gamo Wrote:  This program compare the two "Random Number Generator" by using the "Accumulate Statistic"
and 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.

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:
  • The two RNGs are working independently now. The results are not scaled, so the output is between 0 and 1.
  • You can (and should) store a seed for each RNG in R7 and R8 respectively.
    This is especially important for the 997-RNG. Here the seed should have 7 decimals where the last digit is either 1, 3, 7 or 9.
  • The constants \(\pi\) and 997 are prestored in R9 and R ,0 for faster execution.
  • The summation registers are cleared by the program, the user does not have to care about this.
  • The program does not return any value. Instead you can simply press [\(\bar{x}\)] or [\(s\)] afterwards to get the two means and standard deviations.
The expected mean is 0,5 and the expected standard deviation is sqrt(1/12) = 0,2886... *

Code:
01 STO 0
02 Clear Σ
03 3
04 ,
05 1
06 4
07 1
08 5
09 9
10 2
11 6
12 5
13 4
14 STO 9
15 9
16 9
17 7
18 STO ,0
19 RCL 0
20 X=0?
21 GTO 00
22 RCL 8
23 RCL ,0
24 x
25 FRAC
26 STO 8
27 RCL 7
28 RCL 9
29 +
30 e^x
31 FRAC
32 STO 7
33 Σ+
34 1
35 STO-0
36 GTO 19

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.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (12C) Two Random Generator Comparison - Dieter - 07-26-2018 06:03 PM



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