• ### trigger probability based on percentage

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 :

ROUGH_PROBABiLITY.pd

• Posts 6 | Views 456
• @WEIRD1

whoops, I was missing an inlet - here:

ROUGH_PROBABiLITY_FIX.pd

• @WEIRD1 Here's one way (which could fail on 100% very very infrequently):

• @jameslo said:

@WEIRD1 Here's one way (which could fail on 100% very very infrequently):

It wouldn't fail though, because [random 1000000] yields 0 to 999999, which is guaranteed to be less than 100 * 10000.

hjh

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

Posts 6 | Views 456
Internal error.

Oops! Looks like something went wrong!