csr                 package:splancs                 R Documentation

_G_e_n_e_r_a_t_e _c_o_m_p_l_e_t_e_l_y _s_p_a_t_i_a_l_l_y _r_a_n_d_o_m _p_o_i_n_t_s _o_n _a _p_o_l_y_g_o_n

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

     Generate completely spatially random points on a polygon.

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

     csr(poly,npoints)

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

    poly: A polygon data set. 

 npoints: The number of points to generate. 

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

     'csr' generates points randomly in the bounding box of 'poly,'
     then uses  'pip' to extract those in the polygon. If the number of
     points remaining is less than that required, 'csr' generates some
     more points in the bounding box until at least 'npoints' remain
     inside the polygon. If too many points are generated then the list
     of points is truncated.

     Uses 'runif()' to generate random numbers and so updates
     '.Random.seed', the standard S random number generator seed.

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

     A point data set consisting of 'npoints' points distributed
     randomly, i.e. as an independent random sample from the uniform
     distribution in the polygon defined by 'poly'.

_R_e_f_e_r_e_n_c_e_s:

     Rowlingson, B. and Diggle, P. 1993 Splancs: spatial point pattern
     analysis code in S-Plus.  Computers and Geosciences, 19, 627-655;
     the original sources can be accessed at: <URL:
     http://www.maths.lancs.ac.uk/~rowlings/Splancs/>. See also Bivand,
     R. and Gebhardt, A. 2000 Implementing functions for spatial
     statistical analysis using the R language. Journal of Geographical
     Systems, 2, 307-317.

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

     data(cardiff)
     nsim <- 29
     emp.Ghat <- Ghat(as.points(cardiff), seq(0,30,1))
     av.Ghat <- numeric(length(emp.Ghat))
     U.Ghat <- numeric(length(emp.Ghat))
     L.Ghat <- numeric(length(emp.Ghat))
     U.Ghat <- -99999
     L.Ghat <- 99999
     for(i in 1:nsim) {
     S.Ghat <- Ghat(csr(cardiff$poly, length(cardiff$x)), seq(0,30,1))
     av.Ghat <- av.Ghat + S.Ghat
     L.Ghat <- pmin(S.Ghat, L.Ghat)
     U.Ghat <- pmax(S.Ghat, U.Ghat)
     }
     av.Ghat <- av.Ghat/nsim
     plot(av.Ghat, emp.Ghat, type="l", xlim=c(0,1), ylim=c(0,1), 
     xlab="Simulated average G", ylab="Empirical G")
     lines(c(0,1),c(0,1),lty=2)
     lines(U.Ghat,emp.Ghat,lty=3)
     lines(L.Ghat,emp.Ghat,lty=3)

