Revision 9fc33b4ac23fdcf8e2e93aacb1e9fc5842d57bf3 authored by Adrian Baddeley on 18 December 2007, 00:00:00 UTC, committed by Gabor Csardi on 18 December 2007, 00:00:00 UTC
1 parent 6db367d
Raw File
runifpoint.Rd
\name{runifpoint}
\alias{runifpoint}
\title{Generate N Uniform Random Points}
\description{
  Generate a random point pattern
  containing \eqn{n} independent uniform random points.
}
\usage{
 runifpoint(n, win=owin(c(0,1),c(0,1)), giveup=1000)
}
\arguments{
  \item{n}{
    Number of points.
  }
  \item{win}{
    Window in which to simulate the pattern.
    An object of class \code{"owin"}
    or something acceptable to \code{\link{as.owin}}.
  }
  \item{giveup}{
    Number of attempts in the rejection method after which
    the algorithm should stop trying to generate new points.
  }
}
\value{
  The simulated point pattern (an object of class \code{"ppp"}).
}
\details{
  This function generates \code{n} independent random points,
  uniformly distributed in the window \code{win}.
  (For nonuniform distributions, see \code{\link{rpoint}}.)

  The algorithm depends on the type of window, as follows:
  \itemize{
    \item
    If \code{win} is a rectangle then 
    \eqn{n} independent random points, uniformly distributed
    in the rectangle, are generated by assigning uniform random values to their
    cartesian coordinates.
    \item
    If \code{win} is a binary image mask, then a random sequence of 
    pixels is selected (using \code{\link{sample}})
    with equal probabilities. Then for each pixel in the sequence
    we generate a uniformly distributed random point in that pixel.
    \item
    If \code{win} is a polygonal window, the algorithm uses the rejection
    method. It finds a rectangle enclosing the window,
    generates points in this rectangle, and tests whether they fall in
    the desired window. It gives up when \code{giveup * n} tests
    have been performed without yielding \code{n} successes.
  }
  The algorithm for binary image masks is faster than the rejection
  method but involves discretisation.
}
\seealso{
\code{\link{ppp.object}},
\code{\link{owin.object}},
\code{\link{rpoispp}},
\code{\link{rpoint}}
}
\examples{
 # 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))
}
\author{Adrian Baddeley
  \email{adrian@maths.uwa.edu.au}
  \url{http://www.maths.uwa.edu.au/~adrian/}
  and Rolf Turner
  \email{rolf@math.unb.ca}
  \url{http://www.math.unb.ca/~rolf}
}
\keyword{spatial}
\keyword{datagen}

back to top