I did a google search for log-gamma and then browsed around the documentation. I think the issue is I was poking through the "Special Functions" and statistics functions sections, but the binomial stuff is under the "flonum" section, even though fllog-gamma can be found in "Special Functions." Maybe cross-linking them would help? And perhaps including the word "combinations" or "n choose k" somewhere in the docs for fllog-binomial would make it a bit more searchable for people who are used to different names. <br>
<br><div class="gmail_quote">On Wed, Feb 20, 2013 at 10:51 AM, Neil Toronto <span dir="ltr"><<a href="mailto:neil.toronto@gmail.com" target="_blank">neil.toronto@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
You're welcome!<br>
<br>
A user not finding a documented function is excellent feedback. It means we need to communicate better. Do you remember how you searched for a combinations function?<br>
<br>
Neil ⊥<div class="im"><br>
<br>
On 02/20/2013 08:45 AM, Luke Vilnis wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
Ha! Sorry for not reading the documentation more thoroughly - I hope<br>
this was at least a bit educational to someone besides me :) Fantastic<br>
library and docs, by the way.<br>
<br>
On Wed, Feb 20, 2013 at 10:38 AM, Neil Toronto <<a href="mailto:neil.toronto@gmail.com" target="_blank">neil.toronto@gmail.com</a><br></div><div><div class="h5">
<mailto:<a href="mailto:neil.toronto@gmail.com" target="_blank">neil.toronto@gmail.com</a><u></u>>> wrote:<br>
<br>
On 02/20/2013 06:42 AM, Luke Vilnis wrote:<br>
<br>
No problem. They should be faster even for fairly small numbers<br>
since<br>
they usually require the evaluation of a polynomial (an<br>
approximation of<br>
(log)gamma) versus repeated multiplication/division. From memory the<br>
code should be something like:<br>
<br>
(exp (fllog-gamma (+ 1.0 n)) - (fllog-gamma (+ 1.0 r)) -<br>
(fllog-gamma (+<br>
1.0 (- n r))))<br>
<br>
fllog-gamma should also be faster than bflog-gamma or log-gamma<br>
if you<br>
don't need arbitrary precision. You're also right that this<br>
won't always<br>
give completely exact results - the Racket manual says that the only<br>
exact values are for log gamma of 1 and 2, but this usually is not a<br>
problem.<br>
<br>
PS. It looks like Racket's math collection has a built-in<br>
log-factorial<br>
function too, to avoid all the +1's, so you could try that.<br>
<br>
<br>
There's also `fllog-binomial', which computes the log number of<br>
combinations directly. IIRC, its maximum observed error is 2 ulps.<br>
<br>
Neil ⊥<br>
<br>
<br>
____________________<br>
Racket Users list:<br></div></div>
<a href="http://lists.racket-lang.org/__users" target="_blank">http://lists.racket-lang.org/_<u></u>_users</a><br>
<<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/<u></u>users</a>><br>
<br>
<br>
</blockquote>
<br>
</blockquote></div><br>