简体   繁体   English

如何在给定 m 个点的 4 维空间中有效地找到两个最远的点(欧几里得距离)?

[英]How to efficiently find the two farthest point (Euclidean distance) in an 4-dimensional space given m points?

Given m 4-dimensional points, what is the efficient way to find out the two points that have the maximum Euclidean distance?给定 m 个 4 维点,找出具有最大欧氏距离的两个点的有效方法是什么?

Currently, I am just using brute force approach and checking every pair distance with 2 nested for loops (O(m^2)) but this is very bad as it does not scale.目前,我只是使用蛮力方法并使用 2 个嵌套 for 循环 (O(m^2)) 检查每对距离,但这非常糟糕,因为它无法缩放。

The problem computation scales with the dimensionality.问题计算与维度成比例。 At about 4 you're usually better off with brute force.在大约 4 时,您通常会更好地使用蛮力。

If there's some known functionality for this data you can cut down on things.如果这些数据有一些已知的功能,你可以减少一些事情。 Like if you do this a lot but the points don't change much.就像你经常这样做,但分数没有太大变化。 You can build the grouping by checking each point for the farlest point each time you add a new point caching the data from the brute force.每次添加一个新的点来缓存来自蛮力的数据时,您可以通过检查每个点的最远点来构建分组。 You'd get O(N) on insertion and O(N) on farlest query.你会在插入时得到 O(N),在最远查询时得到 O(N)。 But, you'd need to do that N times giving you O(N^2).但是,你需要这样做 N 次给你 O(N^2)。

You could reduce this a bit if you also clustered the data.如果您还对数据进行了聚类,则可以稍微减少这种情况。 So you define a cluster of points during the insertion and you can determine that since your house is in New York that no house in Paris can be further since you've compared it to a house in Australia.因此,您在插入过程中定义了一组点,并且您可以确定,由于您的房子在纽约,因此巴黎的任何房子都不能更远,因为您已经将它与澳大利亚的房子进行了比较。 You can do that because you have the data in clusters.您可以这样做,因为您拥有集群中的数据。 But, that's not going to save you that much because in 4D things get really hard to optimize because you end up needing way more boxes to store the clusters in 4D and most of the fun optimization is a proof that since you already exceed that distance in 4D you can rule out all the other points.但是,这不会为您节省多少,因为在 4D 中,事情变得非常难以优化,因为您最终需要更多的盒子来存储 4D 中的集群,而且大多数有趣的优化证明,因为您已经超过了在 4D 中的距离4D你可以排除所有其他点。 That's great in 2D but those tricks become progressively messier with new dimensions.这在 2D 中很棒,但随着新维度的出现,这些技巧变得越来越混乱。

Please look at the answer to this question: How to find two most distant points?请看这个问题的答案: 如何找到两个最远的点? To find the convex hull you can use this: https://en.wikipedia.org/wiki/Gift_wrapping_algorithm要找到凸包,您可以使用: https : //en.wikipedia.org/wiki/Gift_wrapping_algorithm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM