Weighted Average of n Floats


    Apr 14 2008 | 3:03 pm
    I'd like to compute a weighted average of an arbitrary number of floats. "lave" from L Objects and the other averaging objects to be found on MaxObjects will only compute an unweighted 1:1:... average as far as I can tell.
    -- Morgan Sutherland

    • Apr 14 2008 | 3:07 pm
      Where are the floats coming from? Could you send a bang each time you get a float, then use counter to count each time you get a float, and continually add the floats, then when you need to find the average, just divide the sum by counter?
    • Apr 14 2008 | 3:22 pm
      Do you meen a histogram? Counting how many times a particular number occurs?
      Cheers Gary Lee Nelson Oberlin College www.timara.oberlin.edu/GaryLeeNelson
      > From: Myrddin_Wyllt > Organization: Cycling '74 > Reply-To: > Date: Mon, 14 Apr 2008 09:07:21 -0600 > To: > Subject: [maxmsp] Re: Weighted Average of n Floats > > > Where are the floats coming from? Could you send a bang each time you get a > float, then use counter to count each time you get a float, and continually > add the floats, then when you need to find the average, just divide the sum by > counter?
    • Apr 14 2008 | 3:25 pm
      Could you describe this approach in a little more detail? I think I see what you're getting at...
      On Mon, Apr 14, 2008 at 11:07 AM, Myrddin_Wyllt wrote: > > Where are the floats coming from? Could you send a bang each time you get a float, then use counter to count each time you get a float, and continually add the floats, then when you need to find the average, just divide the sum by counter? >
      -- Morgan Sutherland
    • Apr 14 2008 | 3:32 pm
      jb.histo located with maxobjects.com in http://www.greyfade.com/joe/max_msp.html
      Total time search to download < 2:00
      Cheers Gary Lee Nelson Oberlin College www.timara.oberlin.edu/GaryLeeNelson
      > From: Myrddin_Wyllt > Organization: Cycling '74 > Reply-To: > Date: Mon, 14 Apr 2008 09:07:21 -0600 > To: > Subject: [maxmsp] Re: Weighted Average of n Floats > > > Where are the floats coming from? Could you send a bang each time you get a > float, then use counter to count each time you get a float, and continually > add the floats, then when you need to find the average, just divide the sum by > counter?
    • Apr 14 2008 | 3:32 pm
      No, I need the mean/average of a number of floats (over any time interval), but I want to weight certain floats that are averaged (like how grades are computing...you know, 50% final exam, 25% problem sets etc.)
      On Mon, Apr 14, 2008 at 11:22 AM, Gary Lee Nelson wrote: > Do you meen a histogram? Counting how many times a particular number > occurs? > > Cheers > Gary Lee Nelson > Oberlin College > www.timara.oberlin.edu/GaryLeeNelson > > > > From: Myrddin_Wyllt > > Organization: Cycling '74 > > Reply-To: > > Date: Mon, 14 Apr 2008 09:07:21 -0600 > > To: > > Subject: [maxmsp] Re: Weighted Average of n Floats > > > > > > > > Where are the floats coming from? Could you send a bang each time you get a > > float, then use counter to count each time you get a float, and continually > > add the floats, then when you need to find the average, just divide the sum by > > counter? > > >
      -- Morgan Sutherland
    • Apr 14 2008 | 3:52 pm
      Sorry, I don't understand how a histogram can achieve what I'm looking for. I need to be able to set the weights myself and I need one float value at the end, the average. Is the idea that I can use the histogram to set the weights? If so, I'm not quite sure how I'd do this...
      On Mon, Apr 14, 2008 at 11:32 AM, Gary Lee Nelson wrote: > jb.histo located with maxobjects.com in > http://www.greyfade.com/joe/max_msp.html > > Total time search to download < 2:00 > > > Cheers > Gary Lee Nelson > Oberlin College > www.timara.oberlin.edu/GaryLeeNelson > > > > From: Myrddin_Wyllt > > Organization: Cycling '74 > > Reply-To: > > Date: Mon, 14 Apr 2008 09:07:21 -0600 > > To: > > Subject: [maxmsp] Re: Weighted Average of n Floats > > > > > > > > Where are the floats coming from? Could you send a bang each time you get a > > float, then use counter to count each time you get a float, and continually > > add the floats, then when you need to find the average, just divide the sum by > > counter? > > >
      -- Morgan Sutherland
    • Apr 14 2008 | 4:04 pm
      Quote: Morgan Sutherland wrote on Mon, 14 April 2008 09:03 ---------------------------------------------------- > I'd like to compute a weighted average of an arbitrary number of > floats.
      ??
    • Apr 14 2008 | 4:45 pm
      Gregory,
      Your patch computes an average for sure, but I'm not entirely sure how the weighting works. If I change it to anything but zero, the output quickly approaches infinity. I also don't know how I'd scale it to handle multiple inputs and multiple weights.
      On Mon, Apr 14, 2008 at 12:04 PM, Gregory Taylor wrote: > > Quote: Morgan Sutherland wrote on Mon, 14 April 2008 09:03 > ---------------------------------------------------- > > > I'd like to compute a weighted average of an arbitrary number of > > floats. > > ?? > > #P window setfont "Sans Serif" 12.; > #P window linecount 1; > #P comment 217 67 79 196620 weighting; > #P flonum 203 42 60 12 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; > #P flonum 119 42 60 12 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; > #P flonum 119 343 60 12 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; > #P newex 203 184 42 196620 !- 1.; > #P newex 203 118 36 196620 t f f; > #P newex 119 120 37 196620 t b f; > #P newex 174 237 39 196620 * 0.9; > #P newex 119 268 65 196620 + 0.; > #P newex 119 238 48 196620 * 0.1; > #P newex 119 208 37 196620 f; > #P comment 131 68 50 196620 data; > #P connect 9 0 5 0; > #P connect 10 0 6 0; > #P connect 3 0 8 0; > #P fasten 3 0 4 0 124 298 222 298 222 225 179 225; > #P connect 7 0 4 1; > #P fasten 6 1 2 1 234 171 162 171; > #P connect 6 0 7 0; > #P connect 5 0 1 0; > #P connect 5 1 1 1; > #P connect 1 0 2 0; > #P connect 2 0 3 0; > #P connect 4 0 3 1; > #P window clipboard copycount 12; > > -- > knowledge is not enough/science is not enough/Love is dreaming this equation > > >
      -- Morgan Sutherland
    • Apr 14 2008 | 7:47 pm
      perhaps have averaging subpatches, then in your main average patch, multiple the numbers according to hwo muc hthey need to be weighted (ie, if its 35% of the total, multiply the number by .35), then add all of the outputs together.
      to get the individual averages of the different floats, take whatever object is outputting the floats, connect it to a patch that will output a bang everytime a float is received (I would post a patch like this, but im at a computer currently w/o Max), say a "sel > 0" object (tho im not sure if you can have > or < in sel, but you get the idea); connect the sel object to a counter to keep track of the number of floats received. Also connect the object outputting the floats to an object to continually add them together (a '+' object, w/ the float outputting object in the right inlet and the number box in the left). Then divide that total by the counter's number.
      Don't know if this is what you're looking for. sorry i cant post a patch. Ill be home later today and if you haven't found a solution by then, ill try to work it out.
    • Apr 14 2008 | 8:49 pm
      "perhaps have averaging subpatches, then in your main average patch, multiple the numbers according to hwo muc hthey need to be weighted (ie, if its 35% of the total, multiply the number by .35), then add all of the outputs together."
      Ah! So simple. No need for you to try it yourself unless you want to. I'll post an abstraction when I have time.
      Thanks Myrddin and everybody else.
      On Mon, Apr 14, 2008 at 3:47 PM, Myrddin_Wyllt wrote: > > perhaps have averaging subpatches, then in your main average patch, multiple the numbers according to hwo muc hthey need to be weighted (ie, if its 35% of the total, multiply the number by .35), then add all of the outputs together. > > to get the individual averages of the different floats, take whatever object is outputting the floats, connect it to a patch that will output a bang everytime a float is received (I would post a patch like this, but im at a computer currently w/o Max), say a "sel > 0" object (tho im not sure if you can have > or < in sel, but you get the idea); connect the sel object to a counter to keep track of the number of floats received. Also connect the object outputting the floats to an object to continually add them together (a '+' object, w/ the float outputting object in the right inlet and the number box in the left). Then divide that total by the counter's number. > > Don't know if this is what you're looking for. sorry i cant post a patch. Ill be home later today and if you haven't found a solution by then, ill try to work it out. > > >
      -- Morgan Sutherland
    • Apr 15 2008 | 1:11 am
      a setting in the right hand box of .5 does a straight average. feed it a set of random numbers and tack a multislider in scroll mode on the bottom and see if it doesn't make more sense.
    • Apr 15 2008 | 8:37 am
      I'd use something like this, no need to scale weights:
    • Dec 03 2009 | 2:58 am
      I ended up using this finally (8 elements max):