python - KDTree Python 实现细节

标签 python algorithm tree scipy binary-tree

我正在研究 scipy 库中的 KDTree 实现,发现自己对这行 https://github.com/scipy/scipy/blob/master/scipy/spatial/kdtree.py#L314-L319 有点困惑

side_distances = np.maximum(0,np.maximum(x-self.maxes,self.mins-x))
if p != np.inf:
    side_distances **= p
    min_distance = np.sum(side_distances)
else:
    min_distance = np.amax(side_distances)

谁能解释一下为什么初始 min_distance 是这样计算的?

最佳答案

min_distancep-norm side_distances 的距离,它又是沿每个维度从 x 到边界框(带内部)的距离。换句话说,min_distance 是从 x 到边界框最近点的距离。

关于python - KDTree Python 实现细节,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31150323/

相关文章:

algorithm - 查找最小排除项 ( MEX )

javascript - 从数组创建对象树

c++ - 二叉搜索树,非递归使用堆栈

python - GPT-3微调错误: Incorrect API key provided

python - SQLite的Python身份验证问题

c - 二叉树前序遍历只打印 NULL

java - 没有 if 条件的三排序

php - 什么 NLP 库适合对共享主机上的英文文本进行基本分析?

python - 有没有办法使用 winsound 暂停音乐?

c++ - 向完整树中添加节点