This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Add uniform_inside_sphere_distribution


On 11/06/2014 02:23 AM, Marc Glisse wrote:
On Wed, 5 Nov 2014, Ed Smith-Rowland wrote:

On 11/05/2014 04:25 PM, Marc Glisse wrote:
On Wed, 5 Nov 2014, Ed Smith-Rowland wrote:

Like the uniform_on_sphere_distribution which is used inside, the 2-dimensional case uses rejection

Could you point out where in the code you are special-casing dimension 2? Somehow I can't see it in the patch.

My miscommunication.  Sorry.

The special casing - and all the hard work - is done by the contained uniform_on_sphere_distribution.

In dimension 2, uniform_on_sphere_distribution generates a uniform random point in the unit disk and projects it to the circle. Using that + one more random number to regenerate a uniform random point in the disk seems wasteful to me.

Good point. I'll check out a direct rejection and see what that gets me time-wise. The ratio is pi/4 which is pretty good.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]