runifpoint: Generate N Uniform Random Points

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/random.R

Description

Generate a random point pattern containing n independent uniform random points.

Usage

1
2
 runifpoint(n, win=owin(c(0,1),c(0,1)), giveup=1000, warn=TRUE, ...,
            nsim=1, drop=TRUE, ex=NULL)

Arguments

n

Number of points.

win

Window in which to simulate the pattern. An object of class "owin" or something acceptable to as.owin.

giveup

Number of attempts in the rejection method after which the algorithm should stop trying to generate new points.

warn

Logical. Whether to issue a warning if n is very large. See Details.

...

Ignored.

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.

ex

Optional. A point pattern to use as the example. If ex is given and n and win are missing, then n and win will be calculated from the point pattern ex.

Details

This function generates n independent random points, uniformly distributed in the window win. (For nonuniform distributions, see rpoint.)

The algorithm depends on the type of window, as follows:

The algorithm for binary image masks is faster than the rejection method but involves discretisation.

If warn=TRUE, then a warning will be issued if n is very large. The threshold is spatstat.options("huge.npoints"). This warning has no consequences, but it helps to trap a number of common errors.

Value

A point pattern (an object of class "ppp") if nsim=1, or a list of point patterns if nsim > 1.

Author(s)

\adrian

and \rolf

See Also

ppp.object, owin.object, rpoispp, rpoint

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
 # 100 random points in the unit square
 pp <- runifpoint(100)
 # irregular window
 data(letterR)
 # polygonal
 pp <- runifpoint(100, letterR)
 # binary image mask
 pp <- runifpoint(100, as.mask(letterR))
 ##
 # randomising an existing point pattern
 runifpoint(npoints(cells), win=Window(cells))
 runifpoint(ex=cells)

Example output

Loading required package: nlme
Loading required package: rpart

spatstat 1.51-0       (nickname: 'Poetic Licence') 
For an introduction to spatstat, type 'beginner' 


Note: spatstat version 1.51-0 is out of date by more than 11 weeks; a newer version should be available.
Planar point pattern: 42 points
window: rectangle = [0, 1] x [0, 1] units
Planar point pattern: 42 points
window: rectangle = [0, 1] x [0, 1] units

spatstat documentation built on Nov. 21, 2017, 9:06 a.m.