Title: | K-Distribution and Weibull Paper |
---|---|
Description: | Density, distribution function, quantile function and random generation for the K-distribution. A plotting function that plots data on Weibull paper and another function to draw additional lines. See results from package in T Lamont-Smith (2018), submitted J. R. Stat. Soc. |
Authors: | Tim Lamont-Smith [aut, cre] |
Maintainer: | Tim Lamont-Smith <[email protected]> |
License: | GPL-3 |
Version: | 0.2 |
Built: | 2025-02-16 05:15:54 UTC |
Source: | https://github.com/cran/kdist |
Density, distribution function, quantile function and random generation for
the K-distribution with parameters shape
and scale
.
dk(x, shape = 1, scale = 1, intensity = FALSE, log = FALSE) pk(q, shape = 1, scale = 1, intensity = FALSE, log.p = FALSE, lower.tail = TRUE) qk(p, shape = 1, scale = 1, intensity = FALSE, log.p = FALSE) rk(n, shape = 1, scale = 1, intensity = FALSE)
dk(x, shape = 1, scale = 1, intensity = FALSE, log = FALSE) pk(q, shape = 1, scale = 1, intensity = FALSE, log.p = FALSE, lower.tail = TRUE) qk(p, shape = 1, scale = 1, intensity = FALSE, log.p = FALSE) rk(n, shape = 1, scale = 1, intensity = FALSE)
x , q
|
vector of quantiles |
shape , scale
|
shape and scale parameters both defaulting to 1. |
intensity |
logical; if TRUE, quantiles are intensities not amplitudes. |
log , log.p
|
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are P[X = x], otherwise, P[X > x]. |
p |
vector of probabilities |
n |
number of observations |
The K-distribution with shape
parameter and
scale
parameter has amplitude density given by
.
Where
is a modified Bessel function of the second kind.
For
, the K-distrubution tends to a Rayleigh
distribution, and for
it is the Exponential
distribution.
The function
base::besselK
is used in the calculation, and
care should be taken with large input arguements to this function,
e.g. very small or
very large.
The cumulative distribution function for
the amplitude,
is given by
.
The K-Distribution is a compound distribution, with Rayleigh
distributed amplitudes (exponential intensities) modulated by another
underlying process whose amplitude is chi-distributed and whose
intensity is Gamma distributed. An Exponential distributed number
multiplied by a Gamma distributed random number is used to
generate the random variates.
The
th moments are given by
, so that the root mean square
value of x is the
scale
factor, .
The function dk
gives the density, pk
gives the distribution
function, qk
gives the quantile function, and rk
generates random variates.
E Jakeman and R J A Tough, "Non-Gaussian models for the statistics of scattered waves", Adv. Phys., 1988, vol. 37, No. 5, pp471-529
Distributions
for other standard distributions, including dweibull
for the Weibull
distribution and dexp
for the exponential distribution.
#===== r <- rk(10000, shape = 3, scale = 5, intensity = FALSE) fn <- stats::ecdf(r) x <- seq(0, 10, length = 100) plot(x, fn(x)) lines(x, pk(x, shape = 3, scale = 5, intensity = FALSE)) #====== r <- rk(10000, shape = 3, scale = 5, intensity = FALSE) d <- density(r) x <- seq(0, 10, length = 100) plot(d, xlim=c(0,10)) lines(x, dk(x, shape = 3, scale = 5, intensity = FALSE))
#===== r <- rk(10000, shape = 3, scale = 5, intensity = FALSE) fn <- stats::ecdf(r) x <- seq(0, 10, length = 100) plot(x, fn(x)) lines(x, pk(x, shape = 3, scale = 5, intensity = FALSE)) #====== r <- rk(10000, shape = 3, scale = 5, intensity = FALSE) d <- density(r) x <- seq(0, 10, length = 100) plot(d, xlim=c(0,10)) lines(x, dk(x, shape = 3, scale = 5, intensity = FALSE))
The kdist package provides two categories of important functions: dk etc, and weiplot.
The kdist functions dk, pk, qk and rk, calculates the K-distribution
weiplot takes data and plots it on Weibull paper. Weilines adds lines to a Weibull plot.
Weibull distributed data plots as a straight line on log-log plot using
wlines()
. It is best used after function wplot()
has been
called.
weilines(x, y, lty = NULL, lwd = NULL, col = "black", type = "l", pch = 0)
weilines(x, y, lty = NULL, lwd = NULL, col = "black", type = "l", pch = 0)
x |
vector of values |
y |
vector of values the same length as x |
lty |
line type |
lwd |
line width |
col |
line color |
type |
type of plotting |
pch |
symbol type for type = "b" |
A Weibull plot uses log paper and has log(1/(1-F(x)) versus x, where the data values x have an empirical cdf of F(x). The plot margins may need to be adjusted so that the right hand axis is visible.
wplot()
creates the Weibull plot
dummy <- c(0,0) weiplot(dummy, xlim = c(1e-3, 10), type = "n") x <- 10^seq(-3, 2, length = 100) weilines(x, pexp(x), col = "red") weilines(x, pweibull(x, 2), col = "blue") weilines(x, pweibull(x, 3), col = "green")
dummy <- c(0,0) weiplot(dummy, xlim = c(1e-3, 10), type = "n") x <- 10^seq(-3, 2, length = 100) weilines(x, pexp(x), col = "red") weilines(x, pweibull(x, 2), col = "blue") weilines(x, pweibull(x, 3), col = "green")
A special type of plot where Weibull distributed data plots as a straight line. This was also originally called Rayleigh paper. Both Rayleigh and exponential distributions also plot as straight lines.
weiplot(data, n = 70, type = "p", xlim = NULL, ylim = c(0.01, 10), main = "Weibull Plot", sub = NULL, ylab = "log(1/1-F(x))", ylab2 = "F(x)", xlab = "x", percent = "False")
weiplot(data, n = 70, type = "p", xlim = NULL, ylim = c(0.01, 10), main = "Weibull Plot", sub = NULL, ylab = "log(1/1-F(x))", ylab2 = "F(x)", xlab = "x", percent = "False")
data |
data values from which a cumulative density function will be
estimated using |
n |
number of points required in plot (default n = 70). |
type |
plot type |
xlim |
the minimum and maximum to be used for the x-axis |
ylim |
the minimum and maximum to be used for the y-axis |
main |
the title of the plot |
sub |
the sub-title of the plot |
ylab |
the title of the left y-axis |
ylab2 |
the title of the right y-axis |
xlab |
the title of the x-axis |
percent |
logical; display right hand axis as percentages |
A Weibull plot uses log paper and has log(1/(1-F(x)) versus x, where the data values x have an empirical cdf of F(x). The plot margins may need to be adjusted so that the right hand axis is visible.
weilines()
adds lines to a Weibull plot
graphics::par(mar = c(5, 5, 5, 5)) r <- rexp(100000) weiplot(r, xlim = c(1e-3, 10)) x <- 10^seq(-3, 2, length = 100) weilines(x, pexp(x))
graphics::par(mar = c(5, 5, 5, 5)) r <- rexp(100000) weiplot(r, xlim = c(1e-3, 10)) x <- 10^seq(-3, 2, length = 100) weilines(x, pexp(x))