# 2013/03/11

## Math fun

Recently I added a few math functions in the core of Gauche, for they were needed to implement some more domain-specific functions.

Just committed are `gamma`

and `lgamma`

,
Gamma function and natural logarithm of
absolute value of it.

(What prompted me to add them was the random variable of
Poisson distribution; the algorithm I found needed `log(n!)`

.
And the reason I was doing Poisson distribution thing was
that I was writing a general random data generator module and
I wanted to cover typical distributions. And the reason that
I was writing such a module was that they were needed for
generative test framework. It's like a domino effect; I'm writing
X, then finds X needs Y, then Y needs Z, etc...)

Some time ago I also added `expt-mod`

, that calculates modulus
exponentiation.

I used to be worried for adding too much stuff to the core library, and tried to put functions together into a module whenever I could attach a suitable name for the bunch. However, some functions are just fundamental enough that appear in different fields now and then, and the core library may be the suitable place for them, after all.

Post a comment