How exactly does the rand() function work
Based on my testing it seems like the rand() function returns a guaranteed set of pseudo-random numbers seeded by the optional 'value' parameter.
For example, if a create a card with a beastmode, the first time a beastmode, calls the rand() function (with no parameters) it will return a value of ~0.69.
The second time the rand() function is called (with no parameters) it will return one of two values...
1) if it is being called/referenced in the same beastmode, or another beastmode, but on the same row of data, the identical value of ~0.69 will be returned... again and again.
2) if it is being called by a different row of data, the next value in the pseudo-random sequence will be returned... in this case ~0.31.
Refreshing the page always returns the same numbers in the same order as listed above. Making a copy of the card returns the same results. Putting the same beastmode formulas into a view returns the same results.
Now if we decide to pass a value into the optional parameter, we will get a different pseudo-random sequence. For example, rand(1) always starts with the sequence ~0.16, ~0.09 and rand(2) always starts with the sequence ~0.52, ~0.58.
This means if you want to use 2 different random numbers within the same row of data in domo you need to call rand() with two different values passed in as the parameter.
Just looking for someone to verify that my understanding of this is correct. I'd check the documentation but first they'd need to create some... =/ and out of curiosity - does anyone else see their instance return the same sequences?
- 7.3K All Categories
- 13 Getting Started in the Community
- 137 Beastmode & Analytics
- 1.8K Data Platform & Data Science
- 52 Domo Everywhere
- 2K Charting
- 997 Ideas Exchange
- 898 Connectors
- 236 Workbench
- 342 APIs
- 76 Apps
- 19 Governance & Productivity
- 233 Use Cases & Best Practices
- 49 News
- 473 Onboarding
- 572 日本支部