TITLE: Closest point to 3 (or more) circles
QUESTION [5 upvotes]: I've been scouring the Internet for enlightenment but so far I've found very little that has helped. To be fair, I'm not a math major and might just not be using the right search queries.
I'm working on a system for outdoor WiFi localization. My experimental data suggests that using the RSSI (received signal strength) gives enough accuracy for the resolution we need, which is where the math - and you good folks - come in. I'd like to use trilateration to find a device's location, possibly using more than 3 beacons with known locations.
With the variability of the RSSI at a given distance it is highly unlikely that trilateration will produce circles with a single common intersection. As such, I need to be able to calculate the point in 2D space that is closest to the edges of all 3+ circles.
At the moment I am coding in python, if that makes a difference to anyone.
What are my options?
Thanks!

REPLY [3 votes]: Let $(x,y)$ be the mystery point and $(w_i,f_i)$ be the sources of the signals; let $m_i$ be the imperfect measurement of the distance between the mystery point and the $i$th signal. Probably the easiest expression to minimize is the sum of the squares of the errors,
$$
E(x,y) = \sum_i \big( (x-w_i)^2 + (y-f_i)^2 - m_i^2 \big)^2
$$
(this expression is easier to handle than the sum of the absolute values of the errors, or the maximum absolute error). You could try to minimize this function like any other function: solve the system of equations
$$
\frac{\partial E}{\partial x}(x,y) = 0, \quad \frac{\partial E}{\partial y}(x,y) = 0
$$
for $x$ and $y$ and verify that it is indeed a minimum. In this case, the partial derivatives would be polynomials of degree 3, which is within the realm of symbolic calculators to solve numerically.
Alternatively, here's a more lowbrow approach. The three measured circles have a total of six points of intersection. Ideally three of those points of intersection would coincide; in practice, though, three of them will be quite close together and the other three will be rather more distant. So compute all six points of intersection; then select the three that are close together; and then take the average of those three (the centroid of the triangle formed from them) as your estimate of the mystery point.