Sampling uniformly distributed random points inside a spherical volume

前端 未结 9 650
无人及你
无人及你 2020-11-27 13:10

I am looking to be able to generate a random uniform sample of particle locations that fall within a spherical volume.

The image below (courtesy of http://nojhan.fre

9条回答
  •  温柔的废话
    2020-11-27 13:26

    Normed gaussian 3d vector is uniformly distributed on sphere, see http://mathworld.wolfram.com/SpherePointPicking.html

    For example:

    N = 1000
    v = numpy.random.uniform(size=(3,N)) 
    vn = v / numpy.sqrt(numpy.sum(v**2, 0))
    

提交回复
热议问题