Thank you for the answers but it seems that neither the solution of Bob
nor the one of Ray works.
I want that each value in a be weighted by both its occurrence in the
list a and by the corresponding weight in w. In other words, with
a={1,1,1,2,3,4} and w={1,1,1,1,2,1}
I want the histogram of b={1,1,1,2,3,3,4}
Obviously this is not what does Bob's proposal.
When w is a list of integers it is if course very easy to construct b
from a and w: just duplicates the elements of a according to their
weights in w.
When a is a list of integers then it seems that the solution of Ray
works (although I don't really understand it).
But when both a and w are lists of real numbers, then it doesn't work.
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 ?
Thanks.