Hello I would like to transcribe r function to generate random numbers in stan. But, I am getting error in stan. The function works fine in r.

Following is the function i created in r

rUL = function(n, par)

{

library(lamW)

u = runif(n)

a=1+par+lambertWm1((1+par)*(exp(-(1+par)))*(u-1))

b = 1+lambertWm1((1+par)*(exp(-(1+par)))*(u-1))

d=a/b

return(d)

}

I would like to transcribe above function in stan. I have used following user defined function but it is giving me error.

functions{

real rUL_rng(real par)

{

real a=1+par+lambert_wm1((1+par)*(exp(-(1+par)))*(uniform_rng(0,1)-1));

real b = 1+lambert_wm1((1+par)*(exp(-(1+par)))*(uniform_rng(0,1)-1));

real d=a/b;

return(d);

}

}

I am getting following error:

SYNTAX ERROR, MESSAGE(S) FROM PARSER:

No matches for:

lambert_wm1(real)

Function lambert_wm1 not found.