At first I had to model the coordinates of two points in a rectangle of 20 m X 30 m. Obviously, these points follow a uniform distribution, so this is the first part of my code:
X1 <- runif(1,0,20)
X2 <- runif(1,0,30)
point1 <- c(X1,X2)
point1
I used the same code for the second point ("point2"), but replaced X1 and X2 with Y1 and Y2 respectively.
Then I had to find the distance between two points:
distance <- sqrt(((X1-Y1)^2)+((X2-Y2)^2))
Now, if I define A as an event, where the points are within 5 to 10 m from each other, I need to find the indicator variable of this event. This is what I got, but I'm not sure if this is correct:
x=0
if (distance < 10 & distance > 5)
{
x=1
}
Z <- c(distance,x)
If I repeated these commands 1000 times, how would I save the values in each simulation and find the maximum and minimum separation values of 1000 repetitions?