Learn R Programming

pumBayes (version 1.0.2)

dtnorm: Density Function for Truncated Normal Distribution

Description

This function calculates the density of a truncated normal distribution at specified points.

Usage

dtnorm(x, mean = 0, sd = 1, lower = -Inf, upper = Inf)

Value

A numeric vector of density values corresponding to the input `x`. The values are normalized to ensure the total probability within the truncation bounds equals 1. Values outside the truncation bounds are set to 0.

Arguments

x

A numeric vector of quantiles at which to evaluate the density.

mean

A numeric value specifying the mean of the normal distribution (default is 0).

sd

A numeric value specifying the standard deviation of the normal distribution (default is 1, must be positive).

lower

A numeric value specifying the lower bound of truncation (default is -Inf).

upper

A numeric value specifying the upper bound of truncation (default is Inf).

Examples

Run this code
dtnorm(c(-1, 0, 1), mean = 0, sd = 1, lower = -1, upper = 1)

Run the code above in your browser using DataLab