dqrng v0.3.1 and tikzDevice v0.12.5

[This article was first published on R on Ralf Stubner, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Today dqrng version 0.3.1 made it unto CRAN and is now propagating to the mirrors.

Kyle Butts provided the implementation for the new dqrrademacher method for drawing Rademacher weights. The Rademacher distribution is equivalent to flipping a fair coin, which can be efficiently implementd by using the raw bit pattern from the RNG directly. See also #50 and #49.

Kyle also suggested a way to support random draws from a multivariate normal distribution by using code from the mvtnorm package, c.f. #46. I didn’t like the idea of mostly duplicating that code within dqrng. Fortunately, Torsten Hothorn (mvtnorm’s author) provided a hook in his code. So now it is possible to supply the source of normally distributed numbers from the outside, i.e. dqrmvnorm is just calling mvtnorm::rmvnorm but requests the usage of dqrnorm. See also #51.

Finally, I have moved the C++ templates that are used for the fast sampling methods to their own header file dqrng_sample.h. This allows using them in parallel computations fixing #26. An example is shown in the parallel vignette.

Originally I had planned to also include support for weighted sampling in this release. This has been requested in #18 and #45 and I had previously had some success with early experiments. Unfortunately the implementation based on these tests had some issues. The performance from the used probabilistic sampling gets really bad, if one (or few) possibilities have much higher weights than the others. To quantify this, one can use max_weight / average_weight, which is a measure for how many tries one needs before a draw is successful.

  • This is 1 for un-weighted distribution or weights.
  • This is (around) 2 for the random distributions used so far.
  • This would be the number of elements in the extreme case where all weight is on one element.

I am not sure yet what a good cut-off point is go for a different algorithm. Or if it would be better to use the alias method right away, c.f. https://www.keithschwarz.com/darts-dice-coins/.

In addition tikzDevice version 0.12.5 made it unto CRAN some time ago, but I forgot to blog about it. This was a rather minor update triggered by a new WARN on CRAN. A recent memoir.cls, used for formatting the vignette, has acquired an incompatibility with the by now ancient float.sty. I decided to just remove the latter and rely more on LaTeX’s standard methods for placing floating environments.

To leave a comment for the author, please follow the link and comment on their blog: R on Ralf Stubner.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)