R

tikzDevice v0.12.4

Yesterday tikzDevice version 0.12.4 made it unto CRAN and is now propagating to the mirrors. The tikzDevice package provides a graphics output device for R that records plots in a LaTeX-friendly format. The device transforms plotting commands issued by R functions into LaTeX code blocks. When included in a paper typeset by LaTeX, these blocks are interpreted with the help of TikZ—a graphics package for TeX and friends written by Till Tantau.

Roulette-wheel selection for dqrng

There is a long standing issue with my {dqrng} package: weighted sampling. Since implementing fast un-weighted sampling methods quite some time ago, I have now started looking into possibilities for weighted sampling. The issue contains a reference to a blog post that is by now only available via the wayback machine. This blog post shows a stochastic acceptance method suggested by Lipowski and Lipowska (2012) (also at https://arxiv.org/abs/1109.3627), which appears very promising.

dqrng v0.3.0

Today dqrng version 0.3.0 made it unto CRAN and is now propagating to the mirrors. This release contains a breaking change: The initial state of dqrng’s RNG is based on R’s RNG, which used to advance R’s RNG state. The implementation has been changed to preserve R’s RNG state, which is less surprising but can change the outcome of current scripts. (#44 fixing #43) In addition, the generation of uniform random numbers now takes a short-cut for min == max and throws an error for min > max (#34 fixing #33)

swephR v0.3.0

This afternoon swephR version 0.3.0 made it unto CRAN and is now propagating to the mirrors. The goal of swephR is to provide an R interface to the Swiss Ephemeris (SE), a high precision ephemeris based upon the DE431 ephemeris from NASA’s JPL. It covers the time range 13201 BCE to 17191 CE. This new version comes with two important changes. First, Victor has finished the laborious task of making all functions from SE’s C API available to R.

tikzDevice v0.12.3

Yesterday tikzDevice version 0.12.3 made it unto CRAN and is now propagating to the mirrors. The tikzDevice package provides a graphics output device for R that records plots in a LaTeX-friendly format. The device transforms plotting commands issued by R functions into LaTeX code blocks. When included in a paper typeset by LaTeX, these blocks are interpreted with the help of TikZ—a graphics package for TeX and friends written by Till Tantau.

XY problems

One can easily fall for an XY problem even when one tries to avoid it.

Numerical integration over an infinite interval in Rcpp (part 2)

In a previous post I have shown that without intervention RcppNumerical does not handle integration over infinite ranges. In this post I want to generalize the method to integrals where only one of the limits is infinite. In addition, I want to make …

swephR v0.2.1

This morning swephR version 0.2.1 made it unto CRAN and is now propagating to the mirrors. The goal of swephR is to provide an R interface to the Swiss Ephemeris, a high precision ephemeris based upon the DE431 ephemeris from NASA’s JPL. It covers the time range 13201 BCE to 17191 CE. This new version comes closely after last week’s release and contains only a single albeit important fix to a stack overflow write found by the UBSAN tests done on CRAN.

swephR v0.2.0

This morning swephR version 0.2.0 made it unto CRAN and is now propagating to the mirrors. The goal of swephR is to provide an R interface to the Swiss Ephemeris, a high precision ephemeris based upon the DE431 ephemeris from NASA’s JPL. It covers the time range 13201 BCE to 17191 CE. The new version 0.2.0 brings two important changes. First, the version of the included Swiss Ephemeris has been updated to the current version 2.

Numerical integration over an infinite interval in Rcpp

On Stack Overflow the question was asked how to numerically integrate a function over a infinite range in Rcpp, e.g. by using RcppNumerical. As an example, the integral \[ \int_{-\infty}^{\infty} \mathrm{d}x \exp\left(-\frac{(x-\mu)^4}{2}\right) \] was given. Using RcppNumerical is straight forward. One defines a class that extends Numer::Func for the function and an interface function that calls Numer::integrate on it: // [[Rcpp::depends(RcppEigen)]] // [[Rcpp::depends(RcppNumerical)]] #include <RcppNumerical.h> class exp4: public Numer::Func { private: double mean; public: exp4(double mean_) : mean(mean_) {} double operator()(const double& x) const { return exp(-pow(x-mean, 4) / 2); } }; // [[Rcpp::export]] Rcpp::NumericVector integrate_exp4(const double &mean, const double &lower, const double &upper) { exp4 function(mean); double err_est; int err_code; const double result = Numer::integrate(function, lower, upper, err_est, err_code); return Rcpp::NumericVector::create(Rcpp::Named("result") = result, Rcpp::Named("error") = err_est); } This works fine for finite ranges: