Build a random number generator in Anaplan
Author: Noah Jackson is a Certified Master Anaplanner and Principal Data and Insights Architect at Anaplan.
Anaplan does not have a RANDOM formula or function, but random numbers can be useful — I was interested in it for generating sample data, but it could potentially be useful for other applications such as Monte Carlo simulations. Fortunately, existing formulas can be used to replicate the most common pseudorandom number generation (PRNG) method used in computing. (I will post links to the full explanation of the mathematics behind this method below.)
A sequence of random-seeming numbers and can be generated in Anaplan using the MOD function and the LAG function. It can be built in a single time dimensioned line item:
Random Number Sequence = MOD(15161346 * LAG(Random Number Sequence, 1, 539346) + 25124523, 1000000)/1000000
This will create a sequence of integers between 0 and 1 that seem to vary randomly. Depending on your needs, that one line item might be all you need! I graphed the first 200 values in the sequence:
https://us.v-cdn.net/6037036/uploads/J8OLEMYGGDP9/randomnumbersequence.png
Going more in depth:
However, the formula above has a limitation: the sequence will always be the same. The first value will always be 0.4442 then 0.8598 then 0.1600 then 0.5505, etc.. This is one of the limitations of computing “random” numbers; they depend on “seed” values to start the sequence. Given the same seed values, the results will be the same. Additionally, the sequence will eventually repeat, but should be plenty long enough for most applications.
If you want unique values, you will need to modify one of the large integers in my original formula — either manually, or by setting them as a reference to a separate line item. It is most common to modify the last value in the LAG formula (539346), as modifying the other values can sometimes create an obvious repeating pattern in your results. If you point it at something that can be changed via import, then every time you run the action you will get a new sequence of results.
If you want a deeper understanding of randomness in computation than I can give here, or to understand the factors for how the MOD function creates pseudo random results, you can read more here:
Hopefully this method is useful to you, or at the very least interesting!
Questions? Leave a comment!