Ralph G Selfridge wrote:
If I want p elements from a set q I can use p?q
But suppose I don't want equal weights attached to the elements of q?
That is if an element of q has a larger weight it is picked more
frequently than p?q provides. The choice is weighted by a separate vector
w (sums to 1).
I presume this is part of a sampling with proportion to size problem or
something similar.
If the weights are rationals mrn then
q =. m # i. #m
~.(p?#q){q
gives the unique elements selected with the required weights. p of course
only has to be less than #q.
Fraser
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm