Forum

Switch randomly between zero and 1 across timespan

Hi All,

I’m trying to create a condition that switches randomly between zero and 1 a set amount of times over a duration in seconds.

I have this so far where 8 random nodes generate a value on load, which then gets remapped between zero and the duration. Then I compare this against the current time of the patch and when greater that it adds 1, which goes into a counter clamped between zero and one.

This is far from ideal as i’d really like to be able to set the amount of times it flips the condition without having to create new random nodes, and to be able to bias it towards one state or the other.

i’ve got as far as thinking i should remap the progression of time from zero to 1, and then generate a randomSpread of values between zero and 1, but then not sure how i would go about using these to test against the progression of time, or how i could bias one state over the other.

I’m new here, and not the best at maths, so if someone could help me out if anything comes to mind that would be amazing :)

Can you describe a bit more what you mean by that?

ok so say you have a state flicking randomly between 0 and 1 over 100 seconds.

you would then apply a bias so that its more likely to be 0, or more likely to be 1.

i would also need a way to control roughly how many times it would switch over those 100 seconds.

something akin to a blinking light, but in my case much slower.

I’ve been messing around with things, this is needlesly complicated. its basically just a random number every frame which is on if < 0.5 then thats run through a damper to control the amount/pace of the switches.

I know to get bias you need to use power but thats about as far as ive got with it…

I guess i could just take a single random number and then run that number through power and change the exponent to control the bias maybe, but perhaps theres a better way to do all this?

Hi!
First about this Bias, there is Round (Value) node witch does pretty much what you want
Second, why don’t you use single Random node and a Bit (Value)
Third if you want to randomize the delay between bangs you can do an LFO feedback loop, to generate next bang timing for you…

BitRandom.v4p (8.6 KB)

hey thanks this is really useful! I ended up doing this:

random2

I generate a random number from the current position of the master track thats driving the whole patch, use a power node to bias it towards 0 or 1, then a damper to control the amount, and an s+h which gets triggered by other events to further cut it down.

yours is nicer though so i think if i just use the power node out of the second map range i’ll have the most control :)

thanks again!

I Would do like this, this way you can decide the exact fraction of on and offs:
RandomFlips.v4p (8.2 KB)

1 Like

Hi sunep this looks really great, thanks! In terms of the threshold value, I assume a lower number preferences a state of 1 because its a greater than? or am i wrong

You are correct, if you multiply the value by 100, you have the percentage of 0s

here in percent
RandomFlipsPercent.v4p (9.7 KB)

and you can swap the inputs on > to get the percentage of 1s or replace it with <