Learn R Programming

spatstat.geom (version 3.2-5)

runifrect: Generate N Uniform Random Points in a Rectangle

Description

Generate a random point pattern, containing \(n\) independent uniform random points, inside a specified rectangle.

Usage

runifrect(n, win = owin(c(0, 1), c(0, 1)), nsim = 1, drop = TRUE)

Value

A point pattern (an object of class "ppp") if nsim=1 and drop=TRUE, otherwise a list of point patterns.

Arguments

n

Number of points.

win

Rectangular window in which to simulate the pattern. An object of class "owin" or something acceptable to as.owin, which must specify a rectangle.

nsim

Number of simulated realisations to be generated.

drop

Logical. If nsim=1 and drop=TRUE (the default), the result will be a point pattern, rather than a list containing a point pattern.

Author

Adrian Baddeley Adrian.Baddeley@curtin.edu.au and Rolf Turner r.turner@auckland.ac.nz

Details

This function is a slightly faster version of runifpoint for the special case where the window is a rectangle.

The function generates n independent random points, uniformly distributed in the window win, by assigning uniform random values to the cartesian coordinates.

For normal usage we recommend runifpoint because it is more flexible. However, runifrect is slightly faster (when the window is a rectangle), and may be preferable in very computationally-demanding tasks.

See Also

ppp.object, owin.object, runifpoint, rpoispp, rpoint

Examples

Run this code
 # 42 random points in the unit square
 pp <- runifrect(42)

Run the code above in your browser using DataLab