[Rd] Fwd: Rcpp sugar dpois

Enrico Bibbona enrico.bibbona at unito.it
Tue Nov 3 12:16:47 CET 2015


Hi. Here is a piece of cpp code.
It works, but I do not understand the rational for the use of
"R::dpois" to call the function dpois since in the examples I have always
found directly "dpois" or "Rcpp::dpois" that both do not work in my code.
Could anyone be so patient to explain me why should it be like that?
Thaks a lot, Enrico

#include <Rcpp.h>
using namespace Rcpp;
NumericVector pcUtildedatoU(NumericVector z, double j, double par)

{
    int l_z=z.size();
    NumericVector out(l_z);
    for (int w=0; w<= (l_z-1); w++)
    {
        double outcand=0;
        double d=z[w];
        if (d >= j)
            outcand=1;
        else if (d>= -j)
        {
            for(int i=-j; i<=d; i+=2)
                outcand+= R::dpois((i+j)/2, par,false)* R::dpois((j-i)/2,
par,false);
            outcand=outcand/R::dpois(j, 2*par,false);
        }
        out[w]=outcand;
    }
    return out;
}

-- 
Enrico Bibbona
Dipartimento di Matematica
Università di Torino
https://sites.google.com/site/enricobibbona/



-- 
Enrico Bibbona
Dipartimento di Matematica
Università di Torino
https://sites.google.com/site/enricobibbona/

	[[alternative HTML version deleted]]



More information about the R-devel mailing list