# Pure Data Vanilla: Random float number generator

I was wondering if it's possible to have a random object that generates floating point numbers within a certain range in Pure Data Vanilla.

For example something that generates a float between 0.0 and 1.0?

• Are you sure you didn't mean to post this on DSP ? Commented Dec 14, 2018 at 20:09

you might want to consider investigating the tag 'randomF'.

• Thanks @Mark that could be an option, but randomF is provided as part of Pd Externals, I was wondering if there is something similar in Pd Vanilla. puredata.info/docs/ListOfPdExternals Commented Dec 15, 2018 at 18:31
• puredata.info/docs/Deken might help bring additional libraries into vanilla.
– Mark
Commented Dec 16, 2018 at 8:54

You could always generate a random number between 0 and 99 (then add 1 to the result to avoid 0) and then divide that number by 100. ex. 50/100 = 0.5

• the issue with this solution is that there is no mention of the pure data objects that could be used for "generating a random number". the [/ ] object can be used to divide the number. so "something" -> [+ 1] -> [/ 100] but the something is what's missing here from this being an answer. Commented Mar 12, 2023 at 21:13

[random] only works with integers and outputs integers from 0 to N - 1 (float inputs are floored), but with a bit of math is possible to use it to get a random float between 0 and 1.

An integer N divided by an integer between 0 and N will aways result in a float between 0 and 1 (in Pure Data 1 / 0 == 0). Since [random] outputs integers from 0 to N - 1 the input to it should be N + 1 and the result is then divide by N. In the example below I have setup 1000 as default, giving 3 digits of precision.