rpoint               package:spatstat               R Documentation

_G_e_n_e_r_a_t_e _N _R_a_n_d_o_m _P_o_i_n_t_s

_D_e_s_c_r_i_p_t_i_o_n:

     Generate a random point pattern containing n independent,
     identically distributed random points with any specified
     distribution.

_U_s_a_g_e:

      rpoint(n, f, fmax=NULL, win=unit.square(), ..., giveup=1000, verbose=FALSE)

_A_r_g_u_m_e_n_t_s:

       n: Number of points to generate. 

       f: The probability density of the points, possibly
          un-normalised. Either a constant, a function 'f(x,y,...)', or
          a pixel image object. 

    fmax: An upper bound on the values of 'f'. If missing, this number
          will be estimated. 

     win: Window in which to simulate the pattern. Ignored if 'f' is a
          pixel image. 

     ...: Arguments passed to the function 'f'. 

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

 verbose: Flag indicating whether to report details of performance of
          the simulation algorithm. 

_D_e_t_a_i_l_s:

     This function generates 'n' independent, identically distributed
     random points with common probability density proportional to 'f'.

     The argument 'f' may be

     _a _n_u_m_e_r_i_c_a_l _c_o_n_s_t_a_n_t: uniformly distributed random points will be
          generated.

     _a _f_u_n_c_t_i_o_n: random points will be generated in the window 'win'
          with probability density proportional to 'f(x,y,...)' where
          'x' and 'y' are the cartesian coordinates. The function 'f'
          must accept  two _vectors_ of coordinates 'x,y' and return
          the corresponding vector of function values. Additional
          arguments '...' of any kind may be passed to the function.

     _a _p_i_x_e_l _i_m_a_g_e: if 'f' is a pixel image object of class '"im"' (see
          'im.object') then random points will be generated in the
          window of this pixel image, with probability density
          proportional to the pixel values of 'f'.

     The algorithm is as follows:

        *  If 'f' is a constant, we invoke 'runifpoint'.

        *  If '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 probability
           'f(x,y,...)/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.

        *  If 'f' is a pixel image, then a random sequence of  pixels
           is selected (using 'sample') with probabilities proportional
           to the pixel values of 'f'.  Then for each pixel in the
           sequence we generate a uniformly distributed random point in
           that pixel.

     The algorithm for pixel images is more efficient than that for
     functions.

_V_a_l_u_e:

     The simulated point pattern (an object of class '"ppp"').

_A_u_t_h_o_r(_s):

     Adrian Baddeley adrian@maths.uwa.edu.au <URL:
     http://www.maths.uwa.edu.au/~adrian/> and Rolf Turner
     rolf@math.unb.ca <URL: http://www.math.unb.ca/~rolf>

_S_e_e _A_l_s_o:

     'ppp.object', 'owin.object', 'runifpoint'

_E_x_a_m_p_l_e_s:

      # 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)

