P is for Practical | |
PerlMonks |
Re^5: Monte Carlo - Coin Tossby roboticus (Chancellor) |
on Mar 13, 2011 at 05:45 UTC ( [id://892904]=note: print w/replies, xml ) | Need Help?? |
Sweet! So of course I had to take another look:
First I put in a trace so I could be sure I wasn't generating useless values. Next, I couldn't bear the zeroes you had to add to your function to match my original return value. They were just sentinel values to simplify the calculation, anyway. So I fixed the original to return only the values of interest. Finally, I had to squeeze a little more speed out of it:
You should've read a bit further down in the wikipedia article you linked. It had a much better algorithm for calculating the coefficients of any row. It saved a nested loop. ...roboticus When your only tool is a hammer, all problems look like your thumb.
In Section
Cool Uses for Perl
|
|