Forums > MaxMSP

probabilty table with an equal sum

February 17, 2009 | 2:17 pm

Hello,

I need some directions. I am trying to make a probability table using anal and prob.
i would like to visualize and use the resulting probability, but I can’s seem to create a table or multislider, which retains an equal sum of all it’s weights.

For example a table with a size of 4 would initially be:

1 (.25)
2 (.25)
3 (.25)
4 (.25)

Say I adjust the weight of value 3 to (.4), my desired table would look like this:

1 (.2)
2 (.2)
3 (.4)
4 (.2)

Very easy, i can do this in a number of ways, using the prob objext or histo with some math. But before I start doing all that work, I am looking for a solution with the table object.

Again the problem is my table goes from:

1 (.25)
2 (.25)
3 (.25)
4 (.25)

to:

1 (.25)
2 (.25)
3 (.4)
4 (.25)

And the sum is no longer (1.)

I am using max4.6
Thank you very much for any help I can get!


February 17, 2009 | 2:58 pm

I found this:

max v2;
#N vpatcher 400 189 745 503;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 214 161 27 196617 + 1;
#P comment 230 24 84 196617 from histo count;
#P comment 143 232 44 196617 to table;
#P comment 42 232 44 196617 to histo;
#P message 171 96 26 196617 128;
#P newex 214 140 40 196617 change;
#P newex 214 121 40 196617 peak;
#P newex 214 50 49 196617 t i i;
#P newex 214 90 49 196617 gate;
#P message 127 102 26 196617 128;
#P newex 214 71 36 196617 > 127;
#P message 127 198 62 196617 tabrange $1;
#P message 25 94 33 196617 clear;
#N comlet reset;
#P inlet 25 24 15 0;
#N comlet from histo count;
#P inlet 214 24 15 0;
#N comlet to histo;
#P outlet 25 231 15 0;
#N comlet to table;
#P outlet 127 231 15 0;
#P comment 42 24 34 196617 reset;
#P connect 4 0 5 0;
#P connect 5 0 2 0;
#P connect 4 0 8 0;
#P connect 8 0 6 0;
#P connect 17 0 6 0;
#P connect 6 0 1 0;
#P connect 5 0 1 0;
#P connect 4 0 13 0;
#P connect 3 0 10 0;
#P connect 10 0 7 0;
#P connect 7 0 9 0;
#P connect 9 0 11 0;
#P connect 11 0 12 0;
#P connect 12 0 17 0;
#P fasten 13 0 11 1 176 116 249 116;
#P connect 10 1 9 1;
#P pop;

In a patch by Chris Muir. The context is not the same as mine, but it addresses the same two objects; histo and table, maybe some scaling algorithm is the only solution?


February 18, 2009 | 3:59 pm

Can anybody help me out, my tables keep exploding!


February 18, 2009 | 7:57 pm

On Wed, 18 Feb 2009, alexander wrote:
-&e->
-&e->Can anybody help me out, my tables keep exploding!
-&e->–
-&e->- Alexander

Not sure exactly what you’re asking, but I was fascinated with the idea of
a self averaging table so I tried one out. It’s actually semi
screwy to do but table has some features that made it easier (table sum,
cool!). In any case, the methods used here should help you even if it’s
off the mark on exactly what you wanted.

andyw

– Pasted Max Patch, click to expand. –

February 18, 2009 | 11:55 pm

Thank you! I have to turn this into a 4.6 patch tomorrow at school, I was actually thinking of using the sum message with table.

The formula for averaging a list is simple divide the index’s increment by the number of other index and subtract that from all of them. Easy but, in the case of a large table, not that easy to patch.


February 23, 2009 | 10:27 pm

Thanks!

It’s close to what I am looking for and gave me all the right iideas. I finished a buggy version in max and I just found out where it goes wrong… a few more days and i will figure this out.


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