public static double exp(double lambda) {
        if (lambda <= 0.0)
            throw new IllegalArgumentException("Rate lambda must be positive");
        return -Math.log(1 - uniform()) / lambda;
    }