Learn R Programming

surveillance (version 1.23.1)

runifdisc: Sample Points Uniformly on a Disc

Description

Sample n points uniformly on a disc of radius r in two-dimensional euclidean space via transformation to polar coordinates: the angle is sampled uniformly from \(U(0,2\pi)\), the length is sampled uniformly from \(\sqrt{U(0,r^2)}\). The sampled polar coordinates are then back-transformed to cartesian coordinates.

Usage

runifdisc(n, r = 1, buffer = 0)

Value

A two-column coordinate matrix of the sampled points.

Arguments

n

integer size of the sample.

r

numeric radius of the disc (centered at (0,0)).

buffer

radius of inner buffer zone without points.

Author

Sebastian Meyer

Examples

Run this code
x <- surveillance:::runifdisc(1000, 3)
plot(x)

Run the code above in your browser using DataLab