MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Weighted histogram

  • To: mathgroup at smc.vnet.net
  • Subject: [mg62319] Re: [mg62287] Re: Weighted histogram
  • From: ggroup at sarj.ca
  • Date: Sat, 19 Nov 2005 23:19:05 -0500 (EST)
  • References: <dliv00$g1b$1@smc.vnet.net><dlkcct$pr0$1@smc.vnet.net> <200511191054.FAA16469@smc.vnet.net>
  • Reply-to: ggroup at sarj.ca
  • Sender: owner-wri-mathgroup at wolfram.com

On Saturday, November 19, 2005 at 05:54 GMT -0500, Kalymereau wrote:

> It is possible to construct a binning and then to fill each bin by the
> corresponding values in a ponderated by the weights in w. But the tests
> I made in this direction were very slow for large lists, and I would
> like something more natural.

> It seems to me to be a very basic problem of data analysis, any other
> idea ?

Well, not really.  The following probably won't win any speed awards,
but it isn't outrageous (about 0.75 minute for 10^6 elements here).

Needs["Graphics`Graphics`"];
n = 10;
m = 10;
a = Table[Random[Real, m], {n}];
w = Table[Random[], {n}];
aw = Transpose[{a, w}];
bins = Table[{i, i + 1}, {i, 0, m - 1}];
Function[x,
      {
        tmp = Select[aw, x[[1]] <= #[[1]] < x[[2]] &];
        aw = Complement[aw, tmp];
        Total[tmp[[All, 2]]],
        Mean[x]
        }
      ] /@ bins // BarChart
Clear[tmp];


  • Prev by Date: Re: Recursion
  • Next by Date: Re: Recursion
  • Previous by thread: Re: Weighted histogram
  • Next by thread: Re: Re: Weighted histogram