Skip to content
Prev 2394 / 10988 Next

[Rcpp-devel] R.e. Fwd: problem with rmultinom function

On Tue, May 31, 2011 at 10:55 AM,
<rcpp-devel-request at r-forge.wu-wien.ac.at> wrote:
I didn't see anything.  If you're not subscribed to the list,
submissions silently fail.  Plus, you must send from the subscribing
address.  I've made this mistake a few times...
I'm attaching a cleanup of the code using inline -- you can now just
source this in R.  I'm not sure, but I think you might be working
under some mistaken assumptions.  Hopefully the attached code is more
conceptually clear.

There were a few offhand things that I modified, e.g. maxItr wasn't
used in the attached code.  There are a number of things that I
*didn't* change for which there seem to be faster/better methods, but
I'm not sure of your purpose.  For example, can any of the in-loop
assignments (qnum, qlength) be moved to the top?

Lastly, are you *just* using rmultinom and Cwhich to roll a K or P
sided die?  If so, what about something like as<int>(runif(1, 0, K))?
Even if you're rolling a weighted die, it seems like there's a better
way...

Hopefully this sheds at least a bit of light on your question.
Apologies if I've misunderstood.
-Christian

## Compile/run from R using the following (assuming inline package is
installed):
source('gibbs.R.txt')
fun1(10)