0

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?

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

3 Answers 3

1

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

2
0

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

1
  • 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.
    – esaruoho
    Commented Mar 12, 2023 at 21:13
0

[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.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.