That's a super cool idea, but my data have no similar size. Anyway, that's
both simple and always better than what I do.(At worst it has an expected
complexity of O(n) if all the mass is in one value and the n-1 are
zero-ish).
I think you can solve the holes on delete by permuting the removed element
with the last element and keeping a map from value to their index.

Thanks you very much for these suggestions.

On Sat, Jun 26, 2010 at 10:04 PM, Garth Sheldon-Coulson <g...@mit.edu>wrote:

> Well, my idea involves rejection sampling. In order to sample an element
> from the set in a mass-weighted fashion, you can sample an element in a
> uniform fashion and then reject the sample with a certain probability (more
> below). If you do reject the sample, you keep drawing from the uniform
> proposal distribution until you get an acceptance. This can be quite
> efficient if the most massive element in the set is not too much more
> massive than the majority of the other elements. If, however, the elements
> have very different masses, then it can be inefficient. Regardless, my
> intuition is that you can't do better than rejection sampling in this case,
> because the probability distribution from which you're sampling is
> constantly changing and not of any particular functional form.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to