prob_norm: Compute and Plot Normal Curve Probabilities over an Interval

View source: R/prob_norm.R

prob_normR Documentation

Compute and Plot Normal Curve Probabilities over an Interval

Description

Calculate the probability of an interval for a normal distribution with specified mean and standard deviation, providing both the numerical probability and a plot of the interval with the corresponding normal curve.

Usage

prob_norm(lo=NULL, hi=NULL, mu=0, sigma=1, nrm_color="black", 
         fill_nrm="grey91", fill_int="slategray3", 
         ylab="", y_axis=FALSE, z=TRUE, axis_size=.9,
         pdf_file=NULL, width=5, height=5, ...)

Arguments

lo

Lowest value in the interval for which to compute probability.

hi

Highest value in the interval for which to compute probability.

mu

Population mean of normal distribution.

sigma

Population standard deviation of normal distribution.

nrm_color

Color of the border of the normal curve.

fill_nrm

Fill color of the normal curve.

fill_int

Fill color of the interval for which the probability is computed.

ylab

Label for the optional vertical axis_

y_axis

If TRUE, then a vertical axis is included.

z

If TRUE, then include z-values on the horizontal-axis_ Set to FALSE if mu=0 and sigma=1.

axis_size

Magnification factor for the axis labels, the value of axis_cex.

pdf_file

Name of the pdf file to which graphics are redirected.

width

Width of the pdf file in inches.

height

Height of the pdf file in inches.

...

Other parameter values for graphics.

Details

Calculate the normal curve probability for the specified interval and normal curve. If there is no upper value of the interval provided, hi, then the upper tail probability is provided, that is, from the specified value until positive infinity. If there is no lower value, lo, then the lower tail probability is provided. The probability is calculated with pnorm.

Value

prob: Calculated probability.

Author(s)

David W. Gerbing (Portland State University; gerbing@pdx.edu)

See Also

pnorm, plot.

Examples

# Mu=0, Sigma=1: Standard normal prob, values between 0 and 2
prob_norm(0,2)

# Mu=0, Sigma=1: Standard normal prob, values lower than 2
prob_norm(hi=2)

# Mu=0, Sigma=1: Standard normal prob, values larger than 2
prob_norm(lo=2)

# Mu=100, Sigma=15: Change default fill color of plotted interval
prob_norm(lo=115, hi=125, mu=100, sigma=15, fill_int="plum")

lessR documentation built on Nov. 12, 2023, 1:08 a.m.