Calculating multiple random numbers with FormulaMap

Hey all, I’m stuck trying to combine Random() and FormulaMap().

The user specifies a start number and an end number. The output should be a list of three different random numbers between the start and end numbers.

Here’s my formula so far:

sequence(1,3,1).formulamap(RandomInteger([Sample Time Start],[Sample Time End]))

This outputs a list of three numbers (e.g., “11, 11, 11”), but they’re all the same random number, i.e., a single random number is generated (within the correct range) and that random number is output three times (copied).

Does anyone know how I can have it generate three different random numbers?

maybe :

sequence(1,3,1).formulamap(RandomInteger([Sample Time Start].nth(currentvalue),[Sample Time End].nth(currentvalue)))

best, christiaan

Thanks for the reply and suggestion. I really don’t understand Nth well…

Output from your suggestion is "8, , " with the following error:

“Wrong argument type: RandomInteger expects parameter to be a number, but found [Sample Time Start].Nth(CurrentValue), which is an unknown value.”

Fwiw, Sample Time Start and End are integers, not formatted as time, so there should be no issue with unexpected format.

sorry, no time for follow-up, great minds like @Johg_Ananda or @Paul_Danyliuk or @Ryan_Martens2 may have better ideas.

1 Like

OK, I have played around with this, and solved it!

It appears the random function returns a doc-wide value, so even playing with formulamap doesn’t seem to get us the result we want.

However, the random value returned does change over time, so I have utilized the hidden delay() function to make it work.

You will see that I generate a values and then wait 18000 milliseconds before generating the next value. If this solution works for you, you can go in and optimize the minimum time for it to work, I wasn’t getting consistent results with anything <8 seconds so I added 10 seconds and it now consistently works.

1 Like

@Andrew_Farnsworth,

I have solved this using a simple trick…
I generate a 6 digit random number and then slice it into 3 two-digit numbers
Which I then scale to be between the Low and High range required.

Max

3 Likes

@Xyzor_Max like the approach sir. well done!