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

s niani riahinaini at gmail.com
Wed Jun 1 20:24:37 CEST 2011

On Wed, Jun 1, 2011 at 3:51 AM, Christian Gunning <xian at unm.edu> wrote:

> 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...
 Yeah, I did the same mistake.

> 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.
> Actually I used .Call for calling the cpp function and as I said this
worked perfectly for small datasets, but for some large datasets,
it doesn't work

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?
> Well, I wrote this attached function just to show the basic structure of my
code, in the original code I have to pick a topic for each word in each
question and also pick a persona for each question in document, and I think
I have no other option.

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...
> yeah, I used Cwhich for that purpose, I will try your suggestion as well,

> 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)
> Thanks you so much for suggesting inline, it really helped me.  I changed
my code to this format and ran it on one of the largest dataset, it is still
running and usually it takes 3,4 days to be completed for 3000 iteration, so
far I haven't seen the former exceptions that happened in .Call version, I
hope it doesn't occur again. I let you know if it ends without any
but still I cant understand why that exceptions happen in .Call version.
Thank you.

> --
> A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal – Panama!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20110601/52915ae3/attachment.htm>

More information about the Rcpp-devel mailing list