Generate a random point pattern in three-dimensional space containing \(n\) independent, identically distributed random points with a specified distribution.
rpoint3(n, f, fmax = NULL, domain = box3(), ...,
nsim = 1, drop = TRUE, ex = NULL, giveup = 1000)A three-dimensional point pattern (an object of class "pp3")
if nsim=1 and drop=TRUE,
otherwise a list of three-dimensional point patterns.
Number of points to generate.
The probability density of the points,
possibly un-normalised.
Either a constant, or a function f(x,y,z, ...).
An upper bound on the values of f.
Three-dimensional box (object of class "box3")
in which to generate the point pattern.
Additional arguments passed to the function f.
Number of simulated realisations to be generated.
Logical. If nsim=1 and drop=TRUE (the default), the
result will be a point pattern, rather than a list
containing a point pattern.
Optional. Example point pattern in three dimensions
(object of class "pp3"). The number of points n
and the spatial region domain will be taken from ex.
Integer. Maximum number of attempts permitted in the rejection method.
Adrian Baddeley Adrian.Baddeley@curtin.edu.au.
This function generates n independent, identically distributed
random points with common probability density proportional to
f inside the specified three-dimensional region domain.
The argument f may be
uniformly distributed random points will be generated.
random points will be generated
in the domain with probability density proportional
to f(x, y, z, ...) where x, y, z
are the cartesian
coordinates. The function f must accept
vectors of coordinates x,y,z and return the corresponding
vector of function values. Additional arguments ... of any kind
may be passed to the function.
The algorithm is as follows:
If f is a constant, we invoke runifpoint3.
If f is a function, then we use the rejection method.
Proposal points are generated from the uniform distribution.
A proposal point \((x,y,z)\) is accepted with probability
f(x,y,z,...)/fmax and otherwise rejected.
The algorithm continues until n points have been
accepted. It gives up after giveup * n proposals
if there are still fewer than n points.
runifpoint3
rpoint3(10, 1)
rpoint3(10, f=function(x,y,z) {sqrt(x)}, fmax=1)
Run the code above in your browser using DataLab