nonuniform sampling with replacement
aram1980 at gmail.com
Mon Mar 22 08:22:01 CET 2010
On 22 мар, 01:28, "Alf P. Steinbach" <al... at start.no> wrote:
> * Alf P. Steinbach:
> > * Jah_Alarm:
> >> I've got a vector length n of integers (some of them are repeating),
> >> and I got a selection probability vector of the same length. How will
> >> I sample with replacement k (<=n) values with the probabilty vector.
> >> In Matlab this function is randsample. I couldn't find anything to
> >> this extent in Scipy or Numpy.
> > <code>
> > </code>
> > Disclaimer: I just cooked it up and just cooked up binary searches
> > usually have bugs. They usually need to be exercised and fixed. But I
> > think you get the idea. Note also that division differs in Py3 and Py2.
> > This is coded for Py3.
> Sorry, I realized this just now: the name "p" in the choice() method is utterly
> misleading, which you can see from the call; it's a random number not a
> probability. I guess my fingers just repeated what they typed earlier.
> - Alf (repeat typist)
thanks a lot
More information about the Python-list