[Ar-list] Innocent question ...

Carter T Butts ctb@andrew.cmu.edu
Tue, 1 Feb 2000 15:07:55 -0500 (EST)


On Mon, 31 Jan 2000, Michael R. Papas wrote:

>             Greetings all,
>     As I seem to have lost most of my information on AR (excepting the hard
> copies (of course)), I am wondering if anyone on 'here' can answer a little
> question for me.  Please forgive the apparent ignorance - consider it a
> make-sure on my part.

No need for apologies...in fact, I don't think anyone has asked this one
before....

> 
>     Does anyone have an ANSI C function that calculates the DRF?  It's
> inverse?  If so, please mail it to either the mailing-list, or to me
> personally - whichever you prefer. ;)  If not, sorry about the bandwidth -
> and I guess that I will just have to figure out a way of doing it. <sigh>

Here are some very straightforward C routines for the DRF and inverse DRF;
just make sure to include math.h, and to link the appropriate libraries
(the -lm option under gcc).  The calculation just follows from that given
in the _PRG_:

double drf(double rating)
{
/*
Everyone's favorite function!!!  The DRF maps -inf to 0 and inf to 1; it's
an S-curve which is close to linear near 0 and starts pulling away
significantly around +/- 30.
*/

return (1.0/PI)*atan(rating/(10*PI))+0.5;
}

double invdrf(double value)
{
/*
This is the inverse of the DRF, above.
*/

if(value<=0.0)                          /* These are safety measures */
        return(-DBL_MAX);
else
        if(value>=1.0)
                return(DBL_MAX);

return (10*PI)*tan(PI*value-PI/2.0);
}


Let me know if there are further questions/problems....

   -Carter