LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Gaussian White Noise - Seed

Hi everybody,

I want to call the "Gaussian White Noise.vi" several times (lets say, in a loop) and thereby, I want to fully control the state of the random generator which is used in the VI.
I think, that the "seed" input somehow determines the state of internal random generator (which is unfortunately "hidden" in a DLL).
So, what I would like to have is an output parameter that returns the last state of the random generator .

The idea is, that I can call the VI several times setting the "seed" input parameter equal to the state of the random generator of the last call. By this, I could get a reproducible stream of random numbers by simply setting the "seed" input parameter of the first call to a user defined value.

I hope, I was able to explain my wishes.

Thanks for all replies

Stefan
0 Kudos
Message 1 of 4
(4,806 Views)
Hello,

I'm not sure exactly what you are asking, how to do that, or will it work?  The how should be a while loop with a shift register.  The shift register will store your previous value, feed it into the seed input and will then store the output.  It seems a little ironic that you would want a reproduceable set of random numbers, but you are correct in stating that the seed determines the random number. 

To get the random number generated, that's a little more rough.  It does not appear that you can get the random number from this vi, but since you have the seed, if you use the same random number generator, you should be able to get the same results.  I might take some playing around with it, but it looks like maybe the Continuous Random.vi or Discrete Random.vi might do the trick for you.

Does this help?
0 Kudos
Message 2 of 4
(4,781 Views)

Stefan,

I *think* that what you need is already available in the "Gaussian White Noise" vi.  If you check the online help, you'll see that the internal state of the random number generator is seeded *only* if you wire in a seed value > 0.  So all you should have to do is to send in a positive value on iteration 0 of your loop and a negative value on all other iterations.  If you run the app twice with the same seed value wired in on iteration 0, you'll produce the exact same pseudo-random stream of gaussian noise.

I've done this a few times myself and can vouch for the repeatability.

-Kevin P.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 3 of 4
(4,767 Views)
Hi Kevin,

thanks for your good idea. This works fine.

If a guy from NI reads this message: It would be helpful anyway, if the state of the random generator would be returned by the VI "Gaussian White Noise.vi". Think about an extensive simulation with a many iterations and after a certain time, an interesting result occurs. If one wants to reinvestigate this interesting result, one has the re-run the complete simulation until one gets to the time instant where the result occurs. If the state of the random generator would be availabe, one could save this state in each iteration and re-running the complete simulation would not be neccessary anymore. One would reload the state of the generator for the interesting iteration and would have to re-run a singe iteration. Would be much faster.

Thanks again

Stefan
0 Kudos
Message 4 of 4
(4,740 Views)