Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement RANDOM_UNIFORM function #385

Open
travisfranck opened this issue Oct 26, 2023 · 1 comment
Open

Implement RANDOM_UNIFORM function #385

travisfranck opened this issue Oct 26, 2023 · 1 comment

Comments

@travisfranck
Copy link
Collaborator

Vensim's RANDOM_UNIFORM (along with other RANDOM_XYZ functions) have not been implemented yet. SDE should support the most used functions, like RANDOM_UNIFORM, RANDOM_POISSON, and RANDOM_NORMAL. Because they all require a random number generator, the suggestion is to focus on one, RANDOM_UNIFORM, to implement the foundation.

Vensim's RANDOM documentation, including the algorithm choice, is documented here:
https://www.vensim.com/documentation/noise_rng.html

A link to some code for the algorithm is here:
https://github.com/MersenneTwister-Lab/SFMT

I asked Vensim forums about tips and pitfalls. TomF provided a good reply on this thread here
https://www.ventanasystems.co.uk/forum/viewtopic.php?p=32192

The highlight of the thread is that:

Equation sorting is deterministic in Vensim, but I'm not sure we could readily tell you exactly what the rules are.
Another source of variation is likely to be calls during initialization - anything that causes one more or one less will break symmetry.

@travisfranck
Copy link
Collaborator Author

Additional thoughts:

  • Someone suggested that reproducing Vensim's random number system is "a fool's errand". They suggested having an exogenous stream of random numbers that drives both Vensim and SDE. That would take the algorithm out of the equation, but maybe not the equation ordering.

Some options for implementation:

  1. Try the above exogenous stream of random numbers (external file)
  2. Try to Vensim's algorithm
  3. Just use C's native rand() function
  4. Find a way to capture Vensim's random numbers and save it to a file, which is then read into SDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant