plot.distribution | R Documentation |
Plot method for an object inheriting from class "distribution"
.
By default the probability density function (p.d.f.), for a continuous
variable, or the probability mass function (p.m.f.), for a discrete
variable, is plotted. The cumulative distribution function (c.d.f.)
will be plotted if cdf = TRUE
. Multiple functions are included
in the plot if any of the parameter vectors in x
has length greater
than 1. See the argument all
.
## S3 method for class 'distribution'
plot(
x,
cdf = FALSE,
p = c(0.1, 99.9),
len = 1000,
all = FALSE,
legend_args = list(),
...
)
x |
an object of class |
cdf |
A logical scalar. If |
p |
A numeric vector. If |
len |
An integer scalar. If |
all |
A logical scalar. If |
legend_args |
A list of arguments to be passed to
|
... |
Further arguments to be passed to |
If xlim
is passed in ...
then this determines the
range of values of the variable to be plotted on the horizontal axis.
If x
is a discrete distribution object then the values for which
the p.m.f. or c.d.f. is plotted is the smallest set of consecutive
integers that contains both components of xlim
. Otherwise,
xlim
is used directly.
If xlim
is not passed in ...
then the range of values spans
the support of the distribution, with the following proviso: if the
lower (upper) endpoint of the distribution is -Inf
(Inf
)
then the lower (upper) limit of the plotting range is set to the
p[1]
\
If the name of x
is a single upper case letter then that name is
used to labels the axes of the plot. Otherwise, x
and
P(X = x)
or f(x)
are used.
A legend is included only if at least one of the parameter vectors in
x
has length greater than 1.
Plots of c.d.f.s are produced using calls to
approxfun
and plot.ecdf
.
An object with the same class as x
, in which the parameter
vectors have been expanded to contain a parameter combination for each
function plotted.
B <- Binomial(20, 0.7)
plot(B)
plot(B, cdf = TRUE)
B2 <- Binomial(20, c(0.1, 0.5, 0.9))
plot(B2, legend_args = list(x = "top"))
x <- plot(B2, cdf = TRUE)
x$size
x$p
X <- Poisson(2)
plot(X)
plot(X, cdf = TRUE)
G <- Gamma(c(1, 3), 1:2)
plot(G)
plot(G, all = TRUE)
plot(G, cdf = TRUE)
C <- Cauchy()
plot(C, p = c(1, 99), len = 10000)
plot(C, cdf = TRUE, p = c(1, 99))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.