[R] Efficient sampling from a discrete distribution in R
Robin Hankin
r.hankin at noc.soton.ac.uk
Tue Sep 4 10:00:34 CEST 2007
On 4 Sep 2007, at 08:40, Issac Trotts wrote:
> On 9/3/07, Prof Brian Ripley <ripley at stats.ox.ac.uk> wrote:
>
>> Yes, vectorize, and don't grow vectors. See 'S
>> Programming' (details in
>> the R FAQ).
>
> It's easy to avoid growing the samples vector but it doesn't seem to
> make much difference. Vectorizing would be probably help, but in this
> algorithm each step depends on the one before it. Do you know of an
> alternative to the Chinese restaurant process that is vectorizable?
>
The Chinese restaurant process is simulated in the untb package,
in what I believe is a reasonably efficient manner.
[I find to my horror that "help.search("Chinese restaurant") returns
empty-handed. I will add a suitable \concept{} entry to untb.Rd]
Best wishes
Robin
>> We've no idea about you (the R posting guide does ask for a signature
>> block), but if this is homework some people are going to be annoyed.
>
> No, it's for my job at Google, so maybe I should use my work email
> address to avoid confusion. Sorry if the questions are so basic that
> they sound like homework, but you and others on the list know things
> that aren't easy to find in the documentation.
>
> --
> Issac Trotts
> Web Operations Chair
> Silicon Valley Web Builder
> http://svwebbuilder.com
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.
--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
tel 023-8059-7743
More information about the R-help
mailing list