# NOT RUN {
x <- seq(0,3, by=0.5)
para <- vec2par(c(0.69, 0.625), type="kmu")
cdfkmu(x, para, marcumQ=TRUE, marcumQmethod="chisq")
cdfkmu(x, para, marcumQ=TRUE, marcumQmethod="delta")
cdfkmu(x, para, marcumQ=FALSE) # about 3 times slower
# }
# NOT RUN {
para <- vec2par(c(0.69, 0.625), type="kmu")
quahi <- supdist(para, delexp=.1)$support[2]
cdfkmu(quahi, para, quahi=quahi)
# }
# NOT RUN {
delx <- 0.01
x <- seq(0,3, by=delx)
plot(c(0,3), c(0,1), xlab="RHO", ylab="cdfkmu(RHO)", type="n")
para <- list(para=c(0, 0.75), type="kmu")
cdf <- cdfkmu(x, para)
lines(x, cdf, col=2, lwd=4)
para <- list(para=c(1, 0.5625), type="kmu")
cdf <- cdfkmu(x, para)
lines(x, cdf, col=3, lwd=4)
kappas <- c(0.00000001, 0.69, 1.37, 2.41, 4.45, 10.48, 28.49)
mus <- c(0.75, 0.625, 0.5, 0.375, 0.25, 0.125, 0.05)
for(i in 1:length(kappas)) {
kappa <- kappas[i]
mu <- mus[i]
para <- list(para=c(kappa, mu), type="kmu")
cdf <- cdfkmu(x, para)
lines(x, cdf, col=i)
}
# }
# NOT RUN {
delx <- 0.005
x <- seq(0,3, by=delx)
nx <- 20*log10(x)
plot(c(-30,10), 10^c(-4,0), log="y", xaxs="i", yaxs="i",
xlab="RHO", ylab="cdfkmu(RHO)", type="n")
m <- 1.25
mus <- c(0.25, 0.50, 0.75, 1, 1.25, 0)
for(mu in mus) {
col <- 1
kappa <- m/mu - 1 + sqrt((m/mu)*((m/mu)-1))
para <- vec2par(c(kappa, mu), type="kmu")
if(! is.finite(kappa)) {
para <- vec2par(c(Inf,m), type="kmu")
col <- 2
}
lines(nx, cdfkmu(x, para), col=col)
}
mtext("Yacoub (2007, figure 4)")
# }
# NOT RUN {
# The Marcum Q use for the CDF avoid numerical integration of pdfkmu(), but
# below is an example for which there is some failure that remains to be found.
para <- vec2par(c(10, 23), type="kmu")
# The following are reliable but slower as they avoid the Marcum Q function
# and use traditional numerical integration of the PDF function.
A <- cdfkmu(c(0.10, 0.35, 0.9, 1, 1.16), para, marcumQ=FALSE)
# Continuing, the first value in c() has an erroneous value for the next call.
B <- cdfkmu(c(0.10, 0.35, 0.9, 1, 1.16), para, marcumQ=TRUE)
# But this distribution is tightly peaks and well away from the origin, so in
# order to snap the erroneous value to zero, we need a successful median
# computation. We can try again using the qualo argument to pass through to
# quakmu() like the following:
C <- cdfkmu(c(0.10, 0.35, 0.9, 1, 1.16), para, marcumQ=TRUE, qualo=0.4)
# The existance of the median for the last one also triggers a truncation of
# the CDF to 0 when negative solution results for the 0.35, although the
# negative is about -1E-14.
# }
# NOT RUN {
# Does the discipline of the signal litature just "know" about the apparent
# upper support of the Kappa-Mu being quite near or even at pi?
"simKMU" <- function() {
km <- 10^runif(2, min=-3, max=3)
f <- cdfkmu(pi, vec2par(km, type="kmu"))
return(c(km, f))
}
EndStudy <- sapply(1:1000, function(i) { simKMU() } )
boxplot(EndStudy[3,])
# }
Run the code above in your browser using DataLab