Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[概率论]以在球面上任意四点为顶点的四面体将球心包含在内的概率 #7

Open
guofei9987 opened this issue Dec 22, 2017 · 10 comments

Comments

@guofei9987
Copy link
Member

以在球面上任意四点为顶点的四面体将球心包含在内的可能性是多少

@guofei9987
Copy link
Member Author

先讨论三角形跟圆对应的概率
先用蒙特卡洛求正确结果

import numpy as np
import numpy as np
import matplotlib.pyplot as plt

def func1_metric(x,x1,x2,is_theta=1):
    # is_theta=1,说明x输入的是极坐标,
    # is_theta=0,说明x输入的是笛卡尔坐标
    if is_theta==1:
        x=[np.cos(x),np.sin(x)]
    elif is_theta==0:
        x=[0,0]
    x1=[np.cos(x1),np.sin(x1)]
    x2=[np.cos(x2),np.sin(x2)]
    return (x[1]-x1[1])*(x2[0]-x1[0])-(x2[1]-x1[1])*(x[0]-x1[0])

def is_in(tri_a):
    for i in range(3):
        tri_a_temp=tri_a.copy()
        tri_a_x0=tri_a_temp.pop(i)
        if func1_metric(tri_a_x0,tri_a_temp[0],tri_a_temp[1])*func1_metric(0,tri_a_temp[0],tri_a_temp[1],is_theta=0)<0:
            return 0
    return 1

试试看:

tri_a=list(np.random.uniform(low=0,high=2*np.pi,size=3))
plt.subplot(111,polar=True)
plt.plot(tri_a,[1,1,1],'r')
plt.plot([tri_a[0],tri_a[-1]],[1,1],'r')
plt.show()
if is_in(tri_a)==0:
    print('不在内部')
else: print('在内部')

模拟:

counts=0
total_counts=100000
for k in range(total_counts):
    tri_a=list(np.random.uniform(low=0,high=2*np.pi,size=3))
    if is_in(tri_a)==1:
        counts+=1
counts/total_counts

输出0.25左右的数

@Joe-C-Ding
Copy link
Contributor

推了一下固定一个点,和不固定之前的关系:
image

@shouldsee
Copy link
Contributor

shouldsee commented Dec 30, 2017

用Jacobian求解球面上的均匀分布

蒙特卡罗得出约为~0.125的结果 (0.12495, 样本量5E6)

猜想 : n维超球面的内接超多面体包含球心的概率是 2^(-n):

  • 数值模拟已确认对 n<=4成立

@shouldsee
Copy link
Contributor

shouldsee commented Dec 31, 2017

@Joe-C-Ding “接下来我们考虑将A映射到0时”
考虑修改为:“考虑将X从[-2pi, 2pi]映射到[0,2pi] ”
或:“现在考虑将A固定在圆周上一点(\theta=0),考察由X所确定的B的分布”

@a234
Copy link

a234 commented Mar 31, 2018

猜想 : n维超球面的内接超多面体包含球心的概率是 2⁻ⁿ
————————————
@shouldsee
正确。
首先证明一个引理:
球面上n+1个点A₁,A₂,...,Aₙ,B张成的内接超多面体包含球心当且仅当-B是A₁,A₂,...,Aₙ的凸组合。
证明:A₁,A₂,...,Aₙ,B张成的内接超多面体包含球心
↔∃c₁,c₂,...,cₙ₊₁:c₁A₁+c₂A₂+...+cₙ(Aₙ)+cₙ₊₁(B)=0
↔∃c₁,c₂,...,cₙ₊₁:c₁/(cₙ₊)A₁+c₂/(cₙ₊₁)A₂+...+cₙ/(cₙ₊₁)(Aₙ)=-B
(此处不考虑B在A₁,A₂,...,Aₙ凸锥锥面上的情况。)
固定A₁,A₂,...,Aₙ,令B在n维超球面上均匀分布。
记[A₁,A₂,...,Aₙ]为A₁,A₂,...,Aₙ凸组合形成的锥
A₁,A₂,...,Aₙ,B包含圆心的概率=-B是A₁,A₂,...,Aₙ凸组合的概率=([A₁,A₂,...,Aₙ]交超球面的面积/超球面的面积)
因此E([A₁,A₂,...,Aₙ]交超球面的面积/超球面的面积)就是n维超球面的内接超多面体包含球心的概率。
现在证明这个概率是2⁻ⁿ.
记([A₁,A₂,...,Aₙ]交超球面的面积/超球面的面积)为f([A₁,A₂,...,Aₙ]).
我们有
f([A₁,A₂,...,Aₙ])与f([A₁,A₂,...,-Aₖ,...,Aₙ])同分布
f([A₁,A₂,...,Aₙ])+......+f([-A₁,-A₂,...,-Aₙ])=1 (“......”取遍±A₁,±A₂,...,±Aₙ的所有2ⁿ种正负号可能)
因此E(f([A₁,A₂,...,Aₙ]))=2⁻ⁿ.
即n维超球面的内接超多面体包含球心的概率是 2⁻ⁿ。

@shouldsee
Copy link
Contributor

shouldsee commented Apr 2, 2018

@a234 Maybe add ( c₁,c₂,...,cₙ₊₁ > 0)?
The combination of convex hull into the sphere seems non-trivial to me.... I'd be grateful if you can add some pictures..

It's also important to note you need 3 points to specify a polygon in a 2-D space, so the original guess was E(f([A₁,A₂,...,Ak]))=2^(-k+1) , where k-1 is the dimension of the super-sphere and k is the number of vertexes to specify the polygon.

But anyway, the simplicity of your proof is appreciated.

@a234
Copy link

a234 commented Apr 3, 2018

@shouldsee There are indeed many bugs in the proof.
The "convex hull of A₁,A₂,...,Aₙ" actually means "the conical combination of OA₁,OA₂,...,OAₙ" where O is the center of the sphere.
And there should be c₁,c₂,...,cₙ₊₁ > 0.

In the proof, the dimension of the hyper-sphere is n and n+1 vertices are used to specify the polygon (A₁,A₂,...,Aₙ,B).

@shouldsee
Copy link
Contributor

Ah of course! I was fooled by "B" xD @a234

@Joe-C-Ding
Copy link
Contributor

看到了球面上的正态分布,和这个问题本身没什么关系了,不过蛮有意思的。有兴趣的可以参考一下 wiki 哈,下面是 一维情形高维情形 的链接。

@shouldsee
Copy link
Contributor

shouldsee commented May 1, 2018

I actually wrote a sampler (notebook) for uniform distribution on a hypersphere recently.... It is a interesting topic to explore, but unfortunately I do not know of efficient sampler yet. The only way I can think of is by normalising multivariate gaussian, which seems prone to NaN.

The hardest part is actually to apply a rotation in higher-dimension systematically (to align two arbitrarily selected vectors), and I have not found a easy solution yet. Formally, given |y|=1,|x|=1, I would like to find a matrix M that satisfies y=Mx and preserve the property of the coordinate system.. The symbolic solution of M is related to wedge product that is easily expressed with differential geometry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants