Re: Error in gamma(delta + (complex(0, 0, 1) * (x - mu))/alpha) : unimplemented complex function

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: Error in gamma(delta + (complex(0, 0, 1) * (x - mu))/alpha) : unimplemented complex function

Hans W Borchers
> I am trying to obtain the grafic of a pdf . but this error keeps showing .
> Here is the code

Or 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]]

______________________________________________
[hidden email] 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.