[racket] Math library kudos

From: Luke Vilnis (lvilnis at gmail.com)
Date: Wed Feb 20 11:39:01 EST 2013

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.

On Wed, Feb 20, 2013 at 10:51 AM, Neil Toronto <neil.toronto at gmail.com>wrote:

> You're welcome!
>
> 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?
>
> Neil ⊥
>
>
> On 02/20/2013 08:45 AM, Luke Vilnis wrote:
>
>> Ha! Sorry for not reading the documentation more thoroughly - I hope
>> this was at least a bit educational to someone besides me :) Fantastic
>> library and docs, by the way.
>>
>> On Wed, Feb 20, 2013 at 10:38 AM, Neil Toronto <neil.toronto at gmail.com
>> <mailto:neil.toronto at gmail.com**>> wrote:
>>
>>     On 02/20/2013 06:42 AM, Luke Vilnis wrote:
>>
>>         No problem. They should be faster even for fairly small numbers
>>         since
>>         they usually require the evaluation of a polynomial (an
>>         approximation of
>>         (log)gamma) versus repeated multiplication/division. From memory
>> the
>>         code should be something like:
>>
>>         (exp (fllog-gamma (+ 1.0 n)) - (fllog-gamma (+ 1.0 r)) -
>>         (fllog-gamma (+
>>         1.0 (- n r))))
>>
>>         fllog-gamma should also be faster than bflog-gamma or log-gamma
>>         if you
>>         don't need arbitrary precision. You're also right that this
>>         won't always
>>         give completely exact results - the Racket manual says that the
>> only
>>         exact values are for log gamma of 1 and 2, but this usually is
>> not a
>>         problem.
>>
>>         PS. It looks like Racket's math collection has a built-in
>>         log-factorial
>>         function too, to avoid all the +1's, so you could try that.
>>
>>
>>     There's also `fllog-binomial', which computes the log number of
>>     combinations directly. IIRC, its maximum observed error is 2 ulps.
>>
>>     Neil ⊥
>>
>>
>>     ____________________
>>       Racket Users list:
>>     http://lists.racket-lang.org/_**_users<http://lists.racket-lang.org/__users>
>>     <http://lists.racket-lang.org/**users<http://lists.racket-lang.org/users>
>> >
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130220/02567767/attachment-0001.html>

Posted on the users mailing list.