class Gamma implements IContinuousDistribution {

    @Override
    public double getDensity(double x) throws DStatException {
        if (x < 0) {
            throw new IllegalArgumentException();
        }
        if (x == 0) {
            if (alpha == 1.0) {
                return 1/beta;
            } else {
                return 0.0;
            }
        }
        if (alpha == 1.0) {
            return Math.exp(-x / beta) / beta;
        }

        return Math.exp((alpha - 1.0) * Math.log(x / beta) - x / beta - logGamma(alpha)) / beta;
    }

    public  Gamma(double alpha, double beta);

}