Learn R Programming

BayesBridge (version 0.6)

rtnorm: Truncated Normal Random Variates

Description

Sample from a truncated normal distribution.

Usage

rtnorm(num=1, mu=0.0, sig=1.0, left=-Inf, right=Inf)

Arguments

num
The number of random variates to generate.
mu
The mean.
sig
The standard deviation.
left
The left truncation point.
right
The right truncation point.

Details

This routine follows Robert (1995) to sample a truncated normal.

For mu, sig, left, and right you may send sequences of parameters in addition to scalars.

References

Christian Robert. Simulation of truncated normal random variables. Statistics and Computing. 1995. Vol 5, p. 121-125.

Examples

Run this code

  samp = rtnorm(100, c(-1.0, 1.0), c(0.5, 0.2), -4, 4);

Run the code above in your browser using DataLab