[SciPy-User] random points within an ellipse

Benjamin Root ben.root@ou....
Wed Aug 4 22:13:03 CDT 2010

On Wed, Aug 4, 2010 at 7:18 PM, alex <argriffi@ncsu.edu> wrote:

> On Wed, Aug 4, 2010 at 7:38 PM, Benjamin Root <ben.root@ou.edu> wrote:
>> Hi,
>> For a project, I need to create sets of random coordinates within a 2d
>> domain.  To start, I have been creating random x and y coordinates, which
>> has worked very nicely.  However, I would like to start doing some fancier
>> domains like ellipses and crescents.  Does anybody know of any useful tricks
>> for doing this?
>> Thanks,
>> Ben Root
> For an ellipse you could start with random points in a disk like this
> http://mathworld.wolfram.com/DiskPointPicking.html
> and then I think you can just stretch along an axis to give the points
> inside the ellipse disk.
> For fancier shapes you can do rejection sampling as long as you can get a
> bounding box and
> you can tell what is inside vs outside the domain.
> Alex
Thanks Alex, that certainly does put me in the correct direction. It appears
that there isn't an analogous expression for an ellipse as there was for a
disc.  I probably will have to just take your suggestion and do some
scaling/rotation upon the set of points to get what I want.  It should be
more than sufficient, and it does look better than my original attempts.

Ben Root
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20100804/bb56a032/attachment-0001.html 

More information about the SciPy-User mailing list