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,

### 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.

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()


[Package EnvStats version 2.8.1 Index]