How do I code a simple random number generator?
When I run the sample code for various random number distributions here:
https://www.vensim.com/documentation/in ... random.htm
They all of produce the same "random" output with every simulation.
Is there a way to have these functions produce a different "random" output when I re-run the simulation?
Thanks!
Generating Random Numbers
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
Re: Generating Random Numbers
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Re: Generating Random Numbers
Okay, thanks, that explains the "seed" functionality.
Is there a way that I can set the seed value to be a different random number every time I run the simulation?
Is there a way that I can set the seed value to be a different random number every time I run the simulation?
-
- Super Administrator
- Posts: 4590
- Joined: Wed Mar 05, 2003 3:10 am
Re: Generating Random Numbers
Advice to posters seeking help (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Units are important!
http://www.bbc.co.uk/news/magazine-27509559
Re: Generating Random Numbers
In sensitivity simulations, you can set the seed to a VECTOR.
See also:
https://www.vensim.com/documentation/noise_seed.htm
https://www.vensim.com/documentation/noise_rng.htm
https://www.vensim.com/documentation/stream_id.htm
See also:
https://www.vensim.com/documentation/noise_seed.htm
https://www.vensim.com/documentation/noise_rng.htm
https://www.vensim.com/documentation/stream_id.htm
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Re: Generating Random Numbers
Dear Tom,
You mentioned that it is possible to do a sensitivity analysis on Seed by using a VECTOR function. However, in the "Sensitivity Simulation Setup" box in the software, there is also another "Noise Seed", which is by difault "1234"!!! Are these Seeds different? if not, then which one is the base for sensitivity? "Noise Seed" or "Seed = VECTOR(Min, Max, Increment)" ?
You mentioned that it is possible to do a sensitivity analysis on Seed by using a VECTOR function. However, in the "Sensitivity Simulation Setup" box in the software, there is also another "Noise Seed", which is by difault "1234"!!! Are these Seeds different? if not, then which one is the base for sensitivity? "Noise Seed" or "Seed = VECTOR(Min, Max, Increment)" ?
Re: Generating Random Numbers
They are different.
The NOISE SEED affects the time varying random streams in the model variables, IF the seed parameter in the function call is 0, like RANDOM UNIFORM(0,1,0). If you use RANDOM UNIFORM(0,1,x) you have to vary x explicitly.
The seed in the sensitivity control file governs the generation of the random sample. "1234" has no particular significance - it could be any integer between 1 and about 2 billion. Referring to "seed" in the control file won't work (unless you also have a constant with that name).
The NOISE SEED affects the time varying random streams in the model variables, IF the seed parameter in the function call is 0, like RANDOM UNIFORM(0,1,0). If you use RANDOM UNIFORM(0,1,x) you have to vary x explicitly.
The seed in the sensitivity control file governs the generation of the random sample. "1234" has no particular significance - it could be any integer between 1 and about 2 billion. Referring to "seed" in the control file won't work (unless you also have a constant with that name).
/*
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/
Advice to posters (it really helps us to help you)
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391
Blog: http://blog.metasd.com
Model library: http://models.metasd.com
Bookmarks: http://delicious.com/tomfid/SystemDynamics
*/