Learn R Programming

triangle (version 0.11)

ltriangle: The Logarithmic Triangle Distribution

Description

These functions provide information about the triangle distribution on the logarithmic interval from a to b with a maximum at c. dltriangle gives the density, pltriangle gives the distribution function, qltriangle gives the quantile function, and rltriangle generates n random deviates.

Usage

dltriangle(x, a=1, b=100, c=10^((log10(a)+log10(b))/2), logbase=10)
pltriangle(q, a=1, b=100, c=10^((log10(a)+log10(b))/2), logbase=10)
qltriangle(p, a=1, b=100, c=10^((log10(a)+log10(b))/2), logbase=10)
rltriangle(n=1, a=1, b=100, c=10^((log10(a)+log10(b))/2), logbase=10)

Arguments

x,q

vector of quantiles.

p

vector of probabilities.

a

lower limit of the distribution.

b

upper limit of the distribution.

c

mode of the distribution.

n

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

logbase

the base of the logarithm to use.

Value

dltriangle gives the density, pltriangle gives the distribution function, qltriangle gives the quantile function, and rltraingle generates random deviates.

Invalid arguments will result in return value NaN or NA.

Details

All probabilities are lower tailed probabilties.

a, b, and c may be appropriate length vectors except in the case of rtriangle.

References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth \& Brooks/Cole.

See Also

.Random.seed about random number generation, runif, etc for other distributions.

Examples

Run this code
# NOT RUN {
## view the distribution
tri <- rltriangle(100000, 1, 100, 10)
hist(log10(tri), breaks=100, main="Triangle Distribution", xlab="x")

dltriangle(10, 1, 100, 10) # 2/(log10(b)-log10(a)) = 1

qltriangle(pltriangle(10)) # 10
# }

Run the code above in your browser using DataLab