runif_triangle: Uniform sampling on/in a triangle

runif_triangleR Documentation

Uniform sampling on/in a triangle

Description

Uniform sampling on or in a triangle (dimension 2).

Usage

runif_in_triangle(n, v1, v2, v3)

runif_on_triangle(n, v1, v2, v3)

Arguments

n

number of simulations

v1, v2, v3

vertices of the triangle

Value

The simulations in a n times 2 matrix.

Examples

sims <- runif_on_triangle(30, c(0,0), c(1,0), c(0,1))
plot(sims, xlim = c(0,1), ylim = c(0,1), pch = 19)
sims <- runif_in_triangle(100, c(0,0), c(1,0), c(0,1))
plot(sims, xlim = c(0,1), ylim = c(0,1), pch = 19)

uniformly documentation built on July 26, 2023, 6:06 p.m.