I am working on a localization project and use a least squares estimate to determine the location of the transmitter. I need a way to statistically characterize the “suitability” of my decision as part of my program, which can be used to tell me if I have a good answer, or if I need additional measurements or bad data. I read a little about using the "Determination Coefficient" or the R-square, but could not find any good examples. Any ideas on how to characterize whether I have a good solution or if additional measurements are needed will be greatly appreciated.
Thank!
My code gives me the following outputs,
grid_lat and grid_lon correspond to the latitude and longitude coordinates for the grid of possible target locations
grid_lat = [[ 38.16755799 38.16755799 38.16755799 38.16755799 38.16755799
38.16755799]
[ 38.17717199 38.17717199 38.17717199 38.17717199 38.17717199
38.17717199]
[ 38.186786 38.186786 38.186786 38.186786 38.186786 38.186786 ]
[ 38.1964 38.1964 38.1964 38.1964 38.1964 38.1964 ]
[ 38.20601401 38.20601401 38.20601401 38.20601401 38.20601401
38.20601401]
[ 38.21562801 38.21562801 38.21562801 38.21562801 38.21562801
38.21562801]
[ 38.22524202 38.22524202 38.22524202 38.22524202 38.22524202
38.22524202]]
grid_lon = [[-75.83805812 -75.83006167 -75.82206522 -75.81406878 -75.80607233
-75.79807588]
[-75.83805812 -75.83006167 -75.82206522 -75.81406878 -75.80607233
-75.79807588]
[-75.83805812 -75.83006167 -75.82206522 -75.81406878 -75.80607233
-75.79807588]
[-75.83805812 -75.83006167 -75.82206522 -75.81406878 -75.80607233
-75.79807588]
[-75.83805812 -75.83006167 -75.82206522 -75.81406878 -75.80607233
-75.79807588]
[-75.83805812 -75.83006167 -75.82206522 -75.81406878 -75.80607233
-75.79807588]
[-75.83805812 -75.83006167 -75.82206522 -75.81406878 -75.80607233
-75.79807588]]
grid_error corresponds to how good it is at solving each point. If we have a 0.0 error, we have a perfect solution. The grid error is calculated for each grid point for each measurement position (traces in the dimension below). Each measurement position has an estimated range for the transmitter. “Error” corresponds to the estimated transmitter range from the measurement, minus the actual range calculated between the location of the measurement range and the grid point. The lower the error, the greater the likelihood that we are close to the actual location of the transmitter.
# Calculate distance between every grid point and every measurement in meters
measured_distance = spatial.distance.cdist(grid_ecef_array, measurement_ecef_array, 'euclidean')
measurement_error = [pow((measurement - estimated_distance),2) for measurement in measured_distance]
mean_squared_error = [numpy.sqrt(numpy.mean(measurement)) for measurement in measurement_error]
# Find minimum solution
# Convert array of mean_squared_errors to 2D grid for graphing
N3, N4 = numpy.array(grid_lon).shape
grid_error = numpy.array(mean_squared_error).reshape((N3, N4))
grid_error = [[ 2.33608445 2.02805063 1.85638288 1.84620283 2.02757163 2.38035108]
[ 1.73675429 1.40649524 1.21799211 1.06503271 1.27373554 1.74265406]
[ 1.44967789 0.96835022 0.62667257 0.52804942 0.91189678 1.50067864]
[ 1.70155286 1.24024402 0.9642869 1.00517531 1.32606411 1.81754752]
[ 2.40218247 2.07449106 1.91044903 1.94272889 2.15511638 2.51683715]
[ 3.29679348 3.05353929 2.93662134 2.95839307 3.11583615 3.39320682]
[ 4.27303679 4.08195869 3.99203754 4.00926823 4.13247105 4.35378011]]
# Generate the 3D plot with the Z coordinate being the mean squared error estimate
plot3Dcoordinates(grid_lon, grid_lat, grid_error)
# Generic function using matplotlib to plot coordinates
def plot3Dcoordinates(X, Y, Z):
fig = plt.figure()
ax = Axes3D(fig)
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet,
linewidth=0, antialiased=False)
fig.colorbar(surf, shrink=0.5, aspect=5)
. , , () , .

, - ( x).
