LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Repeated calls to Random Number Generator "integrate".

Repeated calls to the random number generator tend to "integrate."   If the numbers are truly random, then subtracting 0.5 from each number and adding many of them should give a result close to zero.

I'm running a simulator using the random number generator to add "noise" to the simulated signals.  Data simulated this way tends to "creep" out of range.

I attached a VI to show the behavior.  The random number generator uses the system clock for seeds.  I think it's "beating" against the clock and the results are slowly oscillating positive or negative.

Is this theory likely to be correct?  Is there a workaround?

0 Kudos
Message 1 of 6
(2,906 Views)
Your vi has a bug in it. Remember that the loop iteration [i] starts at 0 so number of samples is [i]+1 not i.
 
Did you know there are other noise generation functions in the Signal Generation palette? You will need to have >= LabVIEW Full Development System.
 
David
0 Kudos
Message 2 of 6
(2,892 Views)
The bug really doesn't exist after a few seconds of operation.  At that point the difference between n and (n+1) is insignificant.  The real problem happens while the while loop runs, not after it completes.
0 Kudos
Message 3 of 6
(2,870 Views)
What you are doing is simulating a one-dimensional random walk, and the result (after many steps) should NOT be zero.

See http://mathworld.wolfram.com/RandomWalk1-Dimensional.html.


0 Kudos
Message 4 of 6
(2,859 Views)
gwd is absolutely right.  The distance from the origin that you are at any given point is a function of the square root of the total number or random steps (or loop iterations) that you have taken.  I have written a quick example that demonstrates this.  This example simulates a random walk and shows how the average distance from the origin is ocillates about the square root of the number of steps.
0 Kudos
Message 5 of 6
(2,847 Views)
In a one-dimensional random walk, all steps have the same amplitude, which is not the case here.
The mean in the long run should really be null. The problem is to what
"in the long run" should mean.
I tried the vi and I found that after 85000 loops the sum reached 0 after having derived down to -70. This is only an example of course; other tests may give different results.

Message Edited by pincpanter on 11-20-2006 05:33 PM

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 6 of 6
(2,829 Views)