pdfPlot {EnvStats} | R Documentation |
Plot Probability Density Function
Description
Produce a probability density function (pdf) plot for a user-specified distribution.
Usage
pdfPlot(distribution = "norm", param.list = list(mean = 0, sd = 1),
left.tail.cutoff = ifelse(is.finite(supp.min), 0, 0.001),
right.tail.cutoff = ifelse(is.finite(supp.max), 0, 0.001),
plot.it = TRUE, add = FALSE, n.points = 1000, pdf.col = "black",
pdf.lwd = 3 * par("cex"), pdf.lty = 1, curve.fill = !add,
curve.fill.col = "cyan", x.ticks.at.all.x.max = 15,
hist.col = ifelse(add, "black", "cyan"), density = 5,
digits = .Options$digits, ..., type = "l", main = NULL, xlab = NULL,
ylab = NULL, xlim = NULL, ylim = NULL)
Arguments
distribution |
a character string denoting the distribution abbreviation. The default value is
|
param.list |
a list with values for the parameters of the distribution. The default value is
|
left.tail.cutoff |
a numeric scalar indicating what proportion of the left-tail of the probability
distribution to omit from the plot. For densities with a finite support minimum
(e.g., Lognormal) the default value is |
right.tail.cutoff |
a scalar indicating what proportion of the right-tail of the probability
distribution to omit from the plot. For densities with a finite support maximum
(e.g., Binomial) the default value is |
plot.it |
a logical scalar indicating whether to create a plot or add to the existing plot
(see |
add |
a logical scalar indicating whether to add the probability density curve to the
existing plot ( |
n.points |
a numeric scalar specifying at how many evenly-spaced points the probability
density function will be evaluated. The default value is |
pdf.col |
for continuous distributions, a numeric scalar or character string determining
the color of the pdf line in the plot.
The default value is |
pdf.lwd |
for continuous distributions, a numeric scalar determining the width of the pdf
line in the plot.
The default value is |
pdf.lty |
for continuous distributions, a numeric scalar determining the line type of
the pdf line in the plot.
The default value is |
curve.fill |
for continuous distributions, a logical value indicating whether to fill in
the area below the probability density curve with the color specified by
|
curve.fill.col |
for continuous distributions, when |
x.ticks.at.all.x.max |
a numeric scalar indicating the maximum number of ticks marks on the |
hist.col |
for discrete distributions, a numeric scalar or character string indicating
what color to use to fill in the histogram if |
density |
for discrete distributions, a scalar indicting the density of line shading for
the histogram when |
digits |
a scalar indicating how many significant digits to print for the distribution
parameters. The default value is |
type , main , xlab , ylab , xlim , ylim , ... |
additional graphical parameters. See |
Details
The probability density function (pdf) of a random variable X
,
usually denoted f
, is defined as:
f(x) = \frac{dF(x)}{dx} \;\;\;\;\;\; (1)
where F
is the cumulative distribution function (cdf) of X
.
That is, f(x)
is the derivative of the cdf
F
with respect to x
(where this derivative exists).
For discrete distributions, the probability density function is simply:
f(x) = Pr(X = x) \;\;\;\;\;\; (2)
In this case, f
is sometimes called the probability function or
probability mass function.
The probability that the random variable X
takes on a value in the interval
[a, b]
is simply the (Lebesgue) integral of the pdf evaluated between
a
and b
. That is,
Pr(a \le X \le b) = \int_a^b f(x) dx \;\;\;\;\;\; (3)
For discrete distributions, Equation (3) translates to summing up the probabilities of all values in this interval:
Pr(a \le X \le b) = \sum_{x \in [a,b]} f(x) = \sum_{x \in [a,b]} Pr(X = x) \;\;\;\;\;\; (4)
A probability density function (pdf) plot plots the values of the pdf against quantiles of the specified distribution. Theoretical pdf plots are sometimes plotted along with empirical pdf plots (density plots), histograms or bar graphs to visually assess whether data have a particular distribution.
Value
pdfPlot
invisibly returns a list giving coordinates of the points
that have been or would have been plotted:
Quantiles |
The quantiles used for the plot. |
Probability.Densities |
The values of the pdf associated with the quantiles. |
Author(s)
Steven P. Millard (EnvStats@ProbStatInfo.com)
References
Forbes, C., M. Evans, N. Hastings, and B. Peacock. (2011). Statistical Distributions. Fourth Edition. John Wiley and Sons, Hoboken, NJ.
Johnson, N. L., S. Kotz, and A.W. Kemp. (1992). Univariate Discrete Distributions, Second Edition. John Wiley and Sons, New York.
Johnson, N. L., S. Kotz, and N. Balakrishnan. (1994). Continuous Univariate Distributions, Volume 1. Second Edition. John Wiley and Sons, New York.
Johnson, N. L., S. Kotz, and N. Balakrishnan. (1995). Continuous Univariate Distributions, Volume 2. Second Edition. John Wiley and Sons, New York.
See Also
Distribution.df
, epdfPlot
, cdfPlot
.
Examples
# Plot the pdf of the standard normal distribution
#-------------------------------------------------
dev.new()
pdfPlot()
#==========
# Plot the pdf of the standard normal distribution
# and a N(2, 2) distribution on the sample plot.
#-------------------------------------------------
dev.new()
pdfPlot(param.list = list(mean=2, sd=2),
curve.fill = FALSE, ylim = c(0, dnorm(0)), main = "")
pdfPlot(add = TRUE, pdf.col = "red")
legend("topright", legend = c("N(2,2)", "N(0,1)"),
col = c("black", "red"), lwd = 3 * par("cex"))
title("PDF Plots for Two Normal Distributions")
#==========
# Clean up
#---------
graphics.off()