note
moritz
First focus on which one is <b>correct</b>. <c>$cosine = sqrt(1 - $sine**2)</c> will only give you non-negative <c>$cosine</c> values, so that solution will only cover 2 of four possible quandrants.
<p>In cases involving random numbers, it helps to know the theory of how probability density functions are transformed; if you don't want to learn the theory, at least create a few hundred or thousand random points with each method you consider, and plot them in some way -- either in a histogram, or in a density plot or so. That way you have a chance to see if the resulting distribution is what you want.
<p>[http://jwenet.net/notebook/2005/1036.html|MJD #11963], <em>It's easy to get the *wrong* answer in O(1) time.</em>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-616540">
[http://perl6.org/|Perl 6 - second systems done right]
</div></div>
929619
929619