Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

And in higher dimensions, extremely slow, as the volume of the sphere fairly rapidly approaches zero, so nearly all your points are outside.

You need to work harder than that, as most of the other comments are pointing out.



Is the rejection method better at low dimensions? If so, where does the gaussian method catch up?


In even dimensions, volume of a sphere of radius 1 is:

    V_{2k} = pi^k/k!
For 10 dimensions, the hypersphere is of volume 2.55, but the enclosing box is of volume 2^10 = 1024. So roughly one in 400 trials gets you a point inside the sphere. Not good odds.


The rejection method is never better I think, work smarter not harder. But it's an easy way to remember and do it. Don't recommend using it when you any actual performance.

In terms of CPU power, calculating the length of the vector and doing a branch, I think, is going to be slower then the proper way to do it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: