Skip to content
Advertisement

How to generate a random sample of points from a 3-D ellipsoid using Python?

I am trying to sample around 1000 points from a 3-D ellipsoid, uniformly. Is there some way to code it such that we can get points starting from the equation of the ellipsoid?

I want points on the surface of the ellipsoid.

Advertisement

Answer

Here is a generic function to pick a random point on a surface of a sphere, spheroid or any triaxial ellipsoid with a, b and c parameters. Note that generating angles directly will not provide uniform distribution and will cause excessive population of points along z direction. Instead, phi is obtained as an inverse of randomly generated cos(phi).

JavaScript

This function is adopted from this post: https://karthikkaranth.me/blog/generating-random-points-in-a-sphere/

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement