Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Repeatable random number simulation

BlazB
6 - Meteoroid

Hi all! I would like to simulate a random number between 0 and 1 for every row of my data in a reproducible way. I am aware I can create random numbers with RAND() in a Formula tool, however they are not reproducible (to my knowledge). Is there a nice way to achieve this? I guess i could create the numbers separately and save the output and just use that for my workflow, however there might be a nicer solution?

 

Thanks,

Blaz

8 REPLIES 8
Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @BlazB,

 

I don't believe there is a way to create a truly random number that could be repeated each time run as this would go against the initial "truly random" idea. The closest i can get is by using the IntToBin() function to convert an integer to its binary value. This way the value would be identical each time run, however wouldn't be between 0 and 1. Otherwise I would go down the same route as you, using the RAND() function and exporting separately.

 

image.png

 

If this solves your issue please mark the answer as correct, if not let me know! I've attached my workflow for you to download if needed.

 

Regards,

Jonathan

BlazB
6 - Meteoroid

Hi @Jonathan-Sherman ,

 

thank you for your reply. I see what you mean with your solution, however it will not be appropriate for my workflow. I will need to go down the mentioned path of exporting the simulation results separately and using those as an input. Not the cleanest way, but will do the trick

 

Thanks again,

Blaz

danilang
19 - Altair
19 - Altair

Hi @BlazB 

 

While the Rand() and RandInt() functions don't accept a seed value, the Simulation Sampling tool does, allowing for a repeatable random number stream.  Configure it as shown below, sample parametrically with a uniform distribution, from 0 to 1

 

s.png

 

Change the number of iterations to be larger than the number of items in your input data. Join the output of this with your data on record position

w.png

resulting in the following random distribution on every run.  Change the seed value to get a new list of random values 

 

r.png

 

Note that the reported seed value is 1 more than the seed set in the Simulation Sampling tool.

 

Dan

 

 

 

 

 

BlazB
6 - Meteoroid

Hi @danilang,

 

thank you very much, your solution does the trick and works perfectly.

 

Cheers,

Blaz

uebelein
6 - Meteoroid

Great job in documenting this solution.

 

Extremely helpful.

Sylvain_Dufour
5 - Atom

This is a great solution. Thanks

stevelogue1980
8 - Asteroid

Throwing this message,when I try to replicate same

stevelogue1980_0-1596144142959.png

 

Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @stevelogue1980,

 

You will need the predictive tools installed in order to successfully run the workflow, further detail on how to install is available at https://help.alteryx.com/current/designer/download-and-use-predictive-tools

 

Regards,

Jonathan

Labels