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];