hello Pure Data Community,
I am working on a simple patch so that I can define the probability of a trigger occurring. Right now my patch is very low resolution, its like 1/2 , 1/3 .... up through 1/10. But how could I build something that had more fine tune capacity ? SO I could define the percentile of likelihood anywhere between 1 and 100 percent probability. Here is my simple patch :
-
trigger probability based on percentage
-
-
@WEIRD1 Here's one way (which could fail on 100% very very infrequently):
-
Also, past a certain point, the extra precision doesn't make much difference... diminishing returns.
( f = { |rand = 100, pct = 25, num = 1000000| var sum = 0; num.do { if(rand.rand < pct) { sum = sum + 1 }; }; sum / num * 100 }; ) // 100 divisions a = Array.fill(100, { f.value }); [a.minItem, a.maxItem, a.mean, a.median] -> [24.9017, 25.1103, 24.999769, 25.0032] // 1000000 divisions a = Array.fill(100, { f.value(1000000, 250000, 1000000) }); [a.minItem, a.maxItem, a.mean, a.median] -> [24.9156, 25.1133, 24.996608, 24.9942]
hjh
-
yeah, I am realizing that *maybe * the one I made is actually not that bad.