On Apr 8, 2012, at 1:28 PM, Guaramy wrote:

Hi, i am writing a function to plot a pdf functions of a Generalized normal
laplace distribution.
The code is this
{
                y = x-rho*mu
        cf.fn = function(s){
                cplex = complex(1,0,1)
                temp1 = alpha*beta*exp(-sigma*s^2/2)
                temp2 = (alpha-cplex*s)*(beta+cplex*s)                          
                out = (temp1/temp2)^rho
                out
                }
        temp.fn = function(s){
                (Mod(cf.fn(s)))*cos(Arg(cf.fn(s))-s*y)
                        }

        int.fn = function(t){sapply(t,FUN=temp.fn)}
te = integrate(int.fn,lower=0,upper=Inf,rel.tol=1e-10,subdivisions=1000000)
        temp3 = ifelse(te$message == "OK",te$value/pi,NA)
        temp3
}
for example if i call the function like this :
GNL.pdf.fn(x[100],mu,sigma,alpha,beta,rho)
there is no problem and as expected a number is returned

but if i try to call it with a sequence of number ex: x = seq(-4,4,0.1)

?Vectorize



this error keeps show in up

Error in integrate(int.fn, lower = 0, upper = Inf) :
 evaluation of function gave a result of wrong length


David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to