# [R] R-help

john lukore johnlukore at gmail.com
Thu Nov 9 04:39:59 CET 2017

```Generate a clustered pattern in [0; 1]2 as follows:

(a) Generate nc, say 20, independent cluster centres (which can be called
parents) that are distributed i.i.d. uniformly in the unit square;

(b) then n daughters are assigned i.i.d. uniformly to these parents and
such that each daughter is located i.i.d. uniformly in a disk of radius r =
0:1 centred at her parent, under the periodic boundary conditions (i.e. the
square = a torus).

My attempt so far is:

set.seed(1) library(spatstat)

n_parent <- 2

n_daughter <- 4

r = 0.1

cnt <- n

W <- disc(radius=3, centre=c(0,0)) i <- 1

while(i <= n_daughter){

d_x <- runif(1)

d_y <- runif(1)

if (d_x ^2+d_y^2 <r) {

i = i+1}}

#need a condition here such that (d_x,d_y) lies in B(0,r)

#where B(0,r) is a ball of center origin and of radius r

In above we should obtain one ball with n_daughters. Next step is to
generate parent centers and distribute the n_daughters in the ball into
n_parents.

[[alternative HTML version deleted]]

```