Forums > MaxMSP

only output certain numbers randomly?

January 17, 2011 | 5:36 pm

I have some data associated with 10 indexes in a coll. I am using a random object to randomize which of those indexes are output from the coll.

However, at times, I only want to use certain indexes, for instance 2, 3, 5, and 6, but I want those particular indexes to be chosen randomly.

Any suggestions on how I might randomly choose among only certain predefined numbers?


January 17, 2011 | 5:46 pm

I would make a random object with the argument 4, and pass it through a coll with the contents:

0, 2;
1, 3;
2, 5;
3, 6;

Or, more likely, I would make a table with 10 x values. I would set all of the y values to 0 except the ones I want to use (2,3,5, and 6) which I would set to 1. Then I would bang the table.

mz


January 17, 2011 | 5:57 pm

A table is a perfect solution. Thanks mzed!


January 17, 2011 | 6:55 pm

table is the best, probably. Though if you don’t need to change the values, you can always use the "non-matching" rightmost outlet of [rotue] or [select]—if one comes out, re-bang the [random]. as long as *some* value eventually gets selected, you won’t get a stack overflow :)


January 18, 2011 | 11:09 am

table is faster indeed. Some efficienty test and others solutions using zl:

– Pasted Max Patch, click to expand. –

Viewing 5 posts - 1 through 5 (of 5 total)