Nakagami Distribution
nakagamiUC.RdDensity, cumulative distribution function, quantile function and random generation for the Nakagami distribution.
Usage
dnaka(x, scale = 1, shape, log = FALSE)
pnaka(q, scale = 1, shape, lower.tail = TRUE, log.p = FALSE)
qnaka(p, scale = 1, shape, ...)
rnaka(n, scale = 1, shape, Smallno = 1.0e-6)Arguments
- x, q
vector of quantiles.
- p
vector of probabilities.
- n
number of observations. Same as in
runif.- scale, shape
arguments for the parameters of the distribution. See
nakagamifor more details. Forrnaka, argumentsshapeandscalemust be of length 1.- Smallno
Numeric, a small value used by the rejection method for determining the upper limit of the distribution. That is,
pnaka(U) > 1-SmallnowhereUis the upper limit.- ...
Arguments that can be passed into
uniroot.- log
Logical. If
log = TRUEthen the logarithm of the density is returned.- lower.tail, log.p
Value
dnaka gives the density,
pnaka gives the cumulative distribution function,
qnaka gives the quantile function, and
rnaka generates random deviates.
Details
See nakagami for more details.
Examples
if (FALSE) x <- seq(0, 3.2, len = 200)
plot(x, dgamma(x, shape = 1), type = "n", col = "black", ylab = "",
ylim = c(0,1.5), main = "dnaka(x, shape = shape)")
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'plot': object 'x' not found
lines(x, dnaka(x, shape = 1), col = "orange")
#> Error: object 'x' not found
lines(x, dnaka(x, shape = 2), col = "blue")
#> Error: object 'x' not found
lines(x, dnaka(x, shape = 3), col = "green")
#> Error: object 'x' not found
legend(2, 1.0, col = c("orange","blue","green"), lty = rep(1, len = 3),
legend = paste("shape =", c(1, 2, 3)))
#> Error in (function (s, units = "user", cex = NULL, font = NULL, vfont = NULL, ...) { if (!is.null(vfont)) vfont <- c(typeface = pmatch(vfont[1L], Hershey$typeface), fontindex = pmatch(vfont[2L], Hershey$fontindex)) .External.graphics(C_strWidth, as.graphicsAnnot(s), pmatch(units, c("user", "figure", "inches")), cex, font, vfont, ...)})(dots[[1L]][[1L]], cex = dots[[2L]][[1L]], font = dots[[3L]][[1L]], units = "user"): plot.new has not been called yet
plot(x, pnorm(x), type = "n", col = "black", ylab = "",
ylim = 0:1, main = "pnaka(x, shape = shape)")
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'plot': object 'x' not found
lines(x, pnaka(x, shape = 1), col = "orange")
#> Error: object 'x' not found
lines(x, pnaka(x, shape = 2), col = "blue")
#> Error: object 'x' not found
lines(x, pnaka(x, shape = 3), col = "green")
#> Error: object 'x' not found
legend(2, 0.6, col = c("orange","blue","green"), lty = rep(1, len = 3),
legend = paste("shape =", c(1, 2, 3))) # \dontrun{}
#> Error in (function (s, units = "user", cex = NULL, font = NULL, vfont = NULL, ...) { if (!is.null(vfont)) vfont <- c(typeface = pmatch(vfont[1L], Hershey$typeface), fontindex = pmatch(vfont[2L], Hershey$fontindex)) .External.graphics(C_strWidth, as.graphicsAnnot(s), pmatch(units, c("user", "figure", "inches")), cex, font, vfont, ...)})(dots[[1L]][[1L]], cex = dots[[2L]][[1L]], font = dots[[3L]][[1L]], units = "user"): plot.new has not been called yet
probs <- seq(0.1, 0.9, by = 0.1)
pnaka(qnaka(p = probs, shape = 2), shape = 2) - probs # Should be all 0
#> [1] -3.427853e-06 -1.984841e-05 2.767343e-05 9.541734e-06 1.030903e-06
#> [6] 4.864279e-06 -5.028646e-07 -1.703812e-05 -1.239174e-08