public double cdf(double p, int k, int n) {
		if (k < 0) return 0;
		if (k >= n) return 1.0;

		double cdf = 0;
		for (int i = 0; i <= k; i++)
			cdf += pdf(p, i, n);

		cdf = Math.min(1.0, cdf);
		return cdf;
	}