
Last chance! 50% off unlimited learning
Sale ends in
rpoint(n, f, fmax=NULL, win=unit.square(), ..., giveup=1000, verbose=FALSE)
f(x,y,...)
, or a pixel image object.f
.
If missing, this number will be estimated.f
is a pixel image.f
."ppp"
).n
independent, identically distributed
random points with common probability density proportional to
f
. The argument f
may be
[object Object],[object Object],[object Object]
The algorithm is as follows:
f
is a constant, we invokerunifpoint
.f
is a function, then we use the rejection method.
Proposal points are generated from the uniform distribution.
A proposal point$(x,y)$is accepted with probabilityf(x,y,...)/fmax
and otherwise rejected.
The algorithm continues untiln
points have been
accepted. It gives up aftergiveup * n
proposals
if there are still fewer thann
points.f
is a pixel image, then a random sequence of
pixels is selected (usingsample
)
with probabilities proportional to the
pixel values off
. Then for each pixel in the sequence
we generate a uniformly distributed random point in that pixel.ppp.object
,
owin.object
,
runifpoint
# 100 uniform random points in the unit square
X <- rpoint(100)
# 100 random points with probability density proportional to x^2 + y^2
X <- rpoint(100, function(x,y) { x^2 + y^2}, 1)
# `fmax' may be omitted
X <- rpoint(100, function(x,y) { x^2 + y^2})
# irregular window
data(letterR)
X <- rpoint(100, function(x,y) { x^2 + y^2}, win=letterR)
# make a pixel image
Z <- setcov(letterR)
# 100 points with density proportional to pixel values
X <- rpoint(100, Z)
Run the code above in your browser using DataLab