在 Python 中创建球体 S^4 上的一个简短的 d 密集点列表

问题描述 投票:0回答:1

我是一名数学家,这是我第一次使用 Stack Overflow,如果问题不充分或者有更好的地方可以问这个问题,我很抱歉。 我想知道是否有标准方法可以执行以下操作。令 d 为某个小距离(例如 d=0.03)。

我想在Python中创建一个球体S^4的点列表L,所以每个点都是一个像[0.5,0.5,0.5,0.5,0]这样的向量,这样S^4的每个点都在距离

最重要的是我们绝对确定S^4的任意一点都在距离

我对如何创建列表有一些想法(例如,在立方体 [-1,1]^5 的边界中取均匀间隔的点,然后将它们投影到 S^4),但它们看起来效率很低,而且我最终会得到至少两倍于所需点数的点,因此我不会得到尽可能小的 d 值。也许某种基于球体三角测量的方法可能会更有效,但我不确定如何实现。总而言之,我只是想知道是否有人已经优化了这个流程。

python algorithm math geometry numerical-methods
1个回答
0
投票

这是一个满足您的标准的简单递归解决方案。

在大于 2 的维度中,它将第一个维度量化为近似最佳数量的点,然后在每个点递归地求解少 1 个维度。

在 2 维时,它只是细分圆。

对于 S^4 上的任意点,只需量化前 3 个坐标,然后找到剩余圆上的最近点,即可找到解中最近的点。

d=0.03 时我获得 21.5M 积分

import math

# count required points on unit n-1-sphere
def countPoints(dims, dmax):
    if dims > 2:
        # for more than 2 dimensions, subdivide the first
        # one and recurse.
        # max distance to point in first dimension
        # d0^2 * dims = dmax^2
        d0 = math.sqrt((dmax * dmax)/dims)
        divisions = math.ceil(1/d0)
        d0 = 1/divisions
        # remaining distance for other dimensions
        # d0^2 + dleft^2 = dmax^2
        dleft = math.sqrt(dmax*dmax - d0*d0)
        total = 0
        x = -1 + d0
        while x < 1:
            # radius in remaining dimensions at point
            # rleft^2 + x^2 = 1
            rleft = math.sqrt(1 - x*x)
            total += countPoints(dims-1, dleft/rleft)
            x += d0*2
        return total
    # in 2 dimensions, just subdivide the circle
    if dmax > 2:
        return 1
    if dmax > math.sqrt(2):
        return 2
    return math.ceil(math.pi/dmax)

print(countPoints(5, 0.03))
© www.soinside.com 2019 - 2024. All rights reserved.