Learn R Programming

jmuOutlier (version 2.2)

rtriang: Triangular Random Generation

Description

Symmetric triangular random generation with endpoints equal to min and max.

Usage

rtriang(n, min = 0, max = 1)

Arguments

n

Number of observations. If length(n)>1, the length is taken to be the number required.

min

Left endpoint of the triangular distribution.

max

Right endpoint of the triangular distribution.

Value

rtriang generates random deviates.

Details

The triangular distribution has density \(4 (x-a) / (b-a)^2\) for \(a \le x \le \mu\), and \(4 (b-x) / (b-a)^2\) for \(\mu < x \le b\), where \(a\) and \(b\) are the endpoints, and the mean of the distribution is \(\mu = (a+b) / 2\).

See Also

dtriang, ptriang, and qtriang.

Examples

Run this code
# NOT RUN {
# 20 random variates from a Triangular( 100, 200 ) distribution.

rtriang( 20, 100, 200 )  
# }

Run the code above in your browser using DataLab