Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

HI i have a questions about using log in perl. i got a formula of term weight which is weight (i , j) = log of (number of documents in collection dived no. of terms i occurs)

however, i do not know how to put that in perl program. can anyone teach me? thanks

$title =~ s/log/logarithms/ - dvergin 2003-02-07

Replies are listed 'Best First'.
Re: how to use log in perl
by robartes (Priest) on Mar 07, 2003 at 06:36 UTC
    From the documentation of log:
    log EXPR log Returns the natural logarithm (base e) of EXPR. If EXPR is omitted, returns log of $_. To get the log of another base, use basic algebra: The base-N log of a number is equal to the natural log of that number divided by the natural log of N. For exampl +e: sub log10 { my $n = shift; return log($n)/log(10); } See also "exp" for the inverse operation.
    Please check your documentation more thoroughly - this was only a perldoc -f log away.

    CU
    Robartes-

A reply falls below the community's threshold of quality. You may see it by logging in.