Trilateration different approaches and issues - trilateration

Although there exists several posts about (multi)lateration, i would like to summarize some approaches and present some issues/questions to better clarify the approach.
It seems that are two ways to detect the target location; using geometric/analytic approach (solving directly the equations with some trick) and fitting approach converting from non-linear to linear system.
With respect to the first one i would like to ask few questions.
Suppose in the presence of perfect range measurements,considering 2D case, the exact solution is a unique point at three circles intersection. Can anyone point some geometric solution for the first case? I found this approach: https://math.stackexchange.com/questions/884807/find-x-location-using-3-known-x-y-location-using-trilateration
but is seems it fails to consider two points with the same y coordinate as we can get a division by 0. Moreover can this be extended to 3D?
The same solution can be extracted using the second approach
Ax=b and latter recovering x = A^-1b or using MLS (x = A^T A)^-1 A^T b.
Please see http://www3.nd.edu/~cpoellab/teaching/cse40815/Chapter10.pdf
What about the case when the three circles have no intersection. It seems that the second approach still finds a solution. Is this normal? How can be explained?
What about the first approach when the range measurements are noisy. Does it find an approximate solution or it fails?
Considering the 3D, it seems that it needs at least 4 anchors to provide a unique solution. However, considering 3 anchors it can provide 2 solutions. I am asking if anyone of u guys can provide such equations to find the two solutions. This can be good even we have two solutions we may discard one by checking the values if they agree with our scenario. E.g., the GPS case where we pick the solution located in the earth. Instead the second approach of LMS would provide always one solution, wrong one.
Do u know any existing library C/C++ which would implement some of this techniques and maybe some more complex fitting functions such as non-linear etc.
Thank you
Regards

Related

Is it a valid approach to copy paste unequal dataset to make em all equal?

I am working with Medical Images (DICOM Images) to classify them into three different class diseases, but I don't have equal distribution of training images for each class. Is it a valid approach to just copy and paste the unequal ones until they all are equal in number? if not what should be a better way ?
You have imbalance in the data and its common. Your solution is essentially oversampling and is a known strategy. I would use a formal solution such as np.random.choice, or np.random.rand and implement a bootstrap. Alternatively, itertools.combinations is another approach
Background There are 3 ways to solve it, one being undersampling, oversampling and the third is changing the performance metric.
If you have a say 30:30:40 imbalance for disease X,Y, and Z. Undersampling is to delete the excess by resample deleting Z to achieve balance.
If you have 15:15:70 for X,Y,Z you might consider oversampling by resampling X, and Y to achieve balance. Personally, I'm not a fan, but just my opinion.
Alternatively you could simply use use precision and recall as performance metrics, rather than accuracy. Thus use precision-recall curves much like ROC.
The best solution of all is simply to collect more data, but this is usually not practical.
In my opinion undersampling is a very good solution but creates problems when you end up deleting very large amounts of data. However, you could of course solve this problem via replicates, or more specifically large numbers of replicates and use your given metric until you are satisfied you've achieved stability.

To know if a quadrilateral intersects another one

I'm looking for an algorithm that allows me to know if a quadrilateral intersects another one. I'm not interested in the intersection itself, I just want to know if it exists.
I have found solutions like the one proposed here: https://math.stackexchange.com/questions/141798/two-quadrilaterals-intersection-area-special-case
But my problem is simpler than the person who wrote this post so there may be a simpler solution too.

Indexing based on Peano-hilbert curve?

I have a x,y,z 3D points stored in MySQL,
I would like to ask the regions, slices or point neighbours.
Are there way to index the points using Peano-Hilbert curves to accelerate the queries?
Or are there more efficient way to store the 3D data in the MySQL?
thanks Arman.
I've personally never went this far, but I used a Z-curve to store 2D points. This worked quite well, and didn't feel the need to try to implement the hilbert curve for better results.
This should allow you to quickly filter out points that certainly are not close by. In an absolute worst case scenario you still need to scan more than 25% of your table to find points within an area.
The way to go about it is to split the x y z in binary and stitch them together into a single value using the curve. I wish I had a SQL script ready, but I just have one for the 2d z-curve which is a much much easier to do.
Edit:
Sorry you might already know all this already and really just looking for SQL samples, but I have some additions:
I'm not sure the 25% worst case scan is true as well for 3D planes. It might be higher, don't have the brainpower right now to tell you ;).
This type of Curve will help you find ranges of where you need to search. If you have 2 coordinates, you can convert these to the hilbert-curve number to find out which section of your table you need to look for items that do exactly match your query.
You might be able to extend this concept to find neighbours, but in order to use the curve you are still 'stuck' to look in ranges.
You can probably take the algorithm to create a geohash, and extend it to 3 coordinates. Basically, you define would have a world cube of possible 3d points, and then as you add more bits, you narrow down the cube. You then consistently define it so that the lower left hand corner has the smallest value, and you can perform range checks like:
XXXXa < the_hash < XXXXz

Route planning from Pt. A to a list of addresses

I wonder if its possible in google maps to plot a the quickest
route from a specific address, Pt A, to a list of destinations
i.e. Pt B, Pt C, Pt D etc. And if that's possible is it available
thru API ? I'll probably need it in the app I'm developing.
Thanks and apologies if this has been asked before !
You may want to check out this project:
Google Maps Fastest Roundtrip Solver
It is available under a GPL license.
The problem you've described is an example of the Traveling Salesman Problem. This is a famous problem because it's an example of the kind of problem that can't be solved efficiently with any known algorithm. That is, you can't come up with the absolutely best answer effiently, because the number of possible solutions increases exponentially. The number of possible solutions is n!, which means 5 x 4 x 3 x 2 x 1, where n=5. Not a big deal in this case, when you are trying to solve for 5 cities, (120 combinations) but even getting up only as far as 10 raises the number of possible combos to 3,628,800. Once you get to 100 nodes, you're counting your CPU time in years. This is why the "Fastest Roundtrip Solver" listed above only guarantees "optimal" solutions up to 15 points.
Having said all that, it can't be solved efficiently, (a "solution" in this case means the one correct answer, as Gebweb says, the "optimal" answer) but you can come up with a pretty good answer, as long as you don't get hung up on it being the absolute provably best one. If you look in the code, you'll notice that Gebweb's Fastest Roundtrip page switches to an "Ant Colony Optimization" (not technically an algorithm, but rather a heuristic) once you get past 15 points. No sense in my repeating what he says better, look at his behind-the-scenes page.
Anyway, Daniel is right, this should do what you want, but I couldn't help but spill a bit about the fact this is a more complex problem than it seems.

Graph Expansion

I'm currently working on an interesting graph problem, I can't find any algorithms or other stackoverflow questions which mention anything like this.
If I have a graph (undirected, cyclic) and a list of commonly used paths, what is the best way to reduce the average path length by adding in N more edges?
EDIT:: Important point, which might help, all paths start at the same node.
Answering my own question, to cover what I've already considered.
The obvious solution is simply to sort the common paths by order, and slot in a connection between the two ends, and keep doing this until you run out of edges to insert. However, I suspect there is a more intelligent solution.
You could just try inserting all possible edges and see how much the shortest path decreases for each of your given start/end points. Pick the best edge and repeat.
The usefulness of edges depends on what other edges have been added, so if you really want optimality, you'd have to try all sets of N edges. That sounds a tad expensive. Wouldn't surprise me if it was NP-hard.
Interesting question!
Another possible solution, which sounds like it might be the best heuristic, is to take the weighted average of all the end nodes (weighted by path importance), then find the node which is closest to the computed average point. Connect to that node.
Obviously that only works if the nodes are laid out in space somehow, but it's a good analogy.