Intersection of two rectangles via Monte Carlo Simulation
Budget: $30 – $250 USD
I would like to estimate the intersection of two rectangles through the Monte Carlo simulation. The algorithm should work for two rotated rectangles.
[1] We determine a random point inside rectangle A through the following instructions.
u, v are random variables between 0 and 1
So that x = A + u AB + v AC will be a random variable inside a rotated rectangle.
A, B, C span our rectangle
[2] Now we check if x is insider rectangle B.
[3] We repeat [1] and [2] giving us an estimate of the overlap between A and B.
The Strong Law of Large Numbers should therefore converge to the mean intersection.
Questions that I want to solve.
* This only gives the us an intersection vs. rectangle B. How can we incorporate this with rectangle B as well?
* How do I know when Monte Carlo has converged in this case. How can I determine if it is accurate to the 3rd etc. position for a floating point number?
[1] We determine a random point inside rectangle A through the following instructions.
u, v are random variables between 0 and 1
So that x = A + u AB + v AC will be a random variable inside a rotated rectangle.
A, B, C span our rectangle
[2] Now we check if x is insider rectangle B.
[3] We repeat [1] and [2] giving us an estimate of the overlap between A and B.
The Strong Law of Large Numbers should therefore converge to the mean intersection.
Questions that I want to solve.
* This only gives the us an intersection vs. rectangle B. How can we incorporate this with rectangle B as well?
* How do I know when Monte Carlo has converged in this case. How can I determine if it is accurate to the 3rd etc. position for a floating point number?