nonuniform sampling with replacement
Alf P. Steinbach
alfps at start.no
Sun Mar 21 08:28:15 EDT 2010
More information about the Python-list mailing list
Sun Mar 21 08:28:15 EDT 2010
- Previous message (by thread): nonuniform sampling with replacement
- Next message (by thread): nonuniform sampling with replacement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
* 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> [snip] > </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. Cheeers, - Alf (repeat typist)
- Previous message (by thread): nonuniform sampling with replacement
- Next message (by thread): nonuniform sampling with replacement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list