Guaramy
2012-Apr-02 17:39 UTC
[R] Error in gamma(delta + (complex(0, 0, 1) * (x - mu))/alpha) : unimplemented complex function
I am trying to obtain the grafic of a pdf . but this error keeps showing . Here is the code MXN.fd = function(x,alpha,beta,mu,delta) { A = (2*cos(beta/2))^(2*delta) B = 2*alpha*pi*gamma(2*delta) C = (beta*(x-mu))/alpha D = abs(gamma(delta + (complex(0,0,1)*(x-mu))/alpha)^2) M = A/B*exp(C)*D M plot(x,M,type="l",lwd=2,col="red") } alpha = 0.02612297 beta = -0.50801886 mu = 0.00575829917 delta = 0.67395 x = x=seq(-0.04,0.04,length=200) MXN.fd(x,alpha,beta,mu,delta) i think the problem is the gamma function, does anyone know how to compute gamma with imaginary numbers? thanks in advance -- View this message in context: http://r.789695.n4.nabble.com/Error-in-gamma-delta-complex-0-0-1-x-mu-alpha-unimplemented-complex-function-tp4526695p4526695.html Sent from the R help mailing list archive at Nabble.com.
Ben Bolker
2012-Apr-02 20:41 UTC
[R] Error in gamma(delta + (complex(0, 0, 1) * (x - mu))/alpha) : unimplemented complex function
Guaramy <Guaramy <at> hotmail.com> writes:>[SNIP]> i think the problem is the gamma function, does anyone know how to compute > gamma with imaginary numbers?Try lngamma_complex() in the gsl package? Ben Bolker
Hans W Borchers
2012-Apr-03 07:31 UTC
[R] Error in gamma(delta + (complex(0, 0, 1) * (x - mu))/alpha) : unimplemented complex function
> I am trying to obtain the grafic of a pdf . but this error keeps showing . > Here is the codeOr use the complex gamma function gammaz() in package 'pracma'. The following code works, that is produces a plot: library(pracma) MXN.fd <- function(x,alpha,beta,mu,delta) { A <- (2*cos(beta/2))^(2*delta) B <- 2*alpha*pi*gamma(2*delta) C <- (beta*(x-mu))/alpha D <- abs(gammaz(delta + (complex(0,0,1)*(x-mu))/alpha)^2) M <- A/B*exp(C)*D plot(x,M,type="l",lwd=2,col="red") } alpha <- 0.02612297; beta <- -0.50801886 mu <- 0.00575829917; delta <- 0.67395 x <- seq(-0.04,0.04,length=200) MXN.fd(x,alpha,beta,mu,delta) grid()> > i think the problem is the gamma function, does anyone know how to compute > gamma with imaginary numbers? > > thanks in advance[[alternative HTML version deleted]]