You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

圆盘内点到边界的平均距离:蒙特卡洛与解析解不符问题排查

圆盘内任意点到边界的平均距离求解(蒙特卡洛模拟与解析解验证)

蒙特卡洛模拟实现

圆盘内均匀采样(Muller方法)

def sample_within(radius, dim, nb_points=1, ):
    # Gaussian-distributed points
    x = np.random.normal(size=(nb_points, dim))

    # Normalize to unit length (points on the surface of the n-sphere)
    x /= np.linalg.norm(x, axis=1)[:, np.newaxis]

    # Random radii with distribution ~ r^(1/n) => uniform volumic distribution in the ball
    r = np.random.rand(nb_points) ** (1/dim)

    # Scale by radius
    points = radius * x * r[:, np.newaxis]
    return points

注:同时采用“立方体采样+丢弃球外点”的笨方法验证,两种采样结果一致。

圆盘边界采样

def sample_on_border(radius, dim:int, nb_points:int):
   # Gaussian-distributed points
   x = np.random.normal(size=(nb_points, dim))

   # Normalize to unit length (points on the surface of the dim-sphere)
   x /= np.linalg.norm(x, axis=1)[:, np.newaxis]

   # Scale by radius
   points = radius * x
   return points

平均距离计算

def calc_average_distance(radius: float, dim: int, nb_in_points: int, nb_border_points: int)->float:
    border_points = sample_on_border(radius, dim, nb_border_points)
    in_points = sample_within(radius, dim, nb_in_points)
    # in_points = border_points #specific case R=1

    distances = np.sqrt(np.sum((border_points[:, np.newaxis, :] - in_points[np.newaxis, :, :])**2, axis=2))
    average_distance_to_border = np.mean(distances)
    return average_distance_to_border 

单位圆盘(半径1)的蒙特卡洛结果

  • 已知验证:单位圆上两点平均距离为$4/\pi \approx 1.27$,蒙特卡洛模拟结果与该值一致;圆心到圆上点的平均距离为1。直觉上目标平均距离d应介于1和1.27之间。
  • 实际计算结果:d = 1.13182±0.00035(5σ置信度),符合预期范围。

解析解的矛盾问题

找到论文《The Average Directional Distance To The Boundary Of A Ball Or Disk》,但发现明显矛盾:

  • 论文给出单位圆两点平均距离为$2/\pi$,与公认的正确值$4/\pi$矛盾;
  • 论文给出的二维圆盘解析解为$8/(3\pi) \approx 0.85$,与蒙特卡洛结果不符。

其他尝试的验证方法

  • 非均匀半径采样(直接均匀采样半径):得到结果1.088,仍与论文的0.85不符;
  • 利用对称性沿[0,1]线段采样:根据采样是否均匀,得到1.13或1.088的结果;
  • 二维极坐标采样:结果仍为1.13,与Muller方法的蒙特卡洛结果一致。

此外,参考3D球的相关问题,蒙特卡洛结果与结论$6/5$一致,但与上述论文给出的$3/4$结论不符。

推测与请求

推测正确的二维圆盘解析值应为$32/(9\pi)$,请求协助排查推理或代码中的错误。

内容的提问来源于stack exchange,提问作者louis

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 22:23:19