public BinomialParameters estimateBinomialParameters() {
		double[] x = toDistribution(this.x);
		// int[] xmins = ArraysExt.unique(this.x);
		// Arrays.sort(xmins);
		// xmins = Arrays.copyOf(xmins, xmins.length - 1);
		int[] xmins = new int[]{0, 1};
		int[] shiftings = ArraysExt.range(-ArraysExt.max(this.x), 1);
		// int[] shiftings = new int[1];

		double[] ps = new double[100];
		for (int i = 1; i < ps.length; i++)
			ps[i - 1] = i / 100.0;

		// int[] ns = new int[100];
		// for (int i = 0; i < ns.length; i++)
		// ns[i] = i + 1;
		// int[] ns = ArraysExt.range(10,ArraysExt.max(this.x)/2);
		// int[] ns = ArraysExt.range(10,ArraysExt.max(this.x));
		int[] ns = ArraysExt.range(10, 21);

		double minDist = Double.MAX_VALUE;
		int minXmin = -1;
		double[] xMinDistribution = null;
		double minP = -1;
		int minN = -1;
		int minShifting = -1;

		for (double p : ps) {
			for (int n : ns) {
				for (int shifting : shiftings) {
					if (Math.abs(shifting) >= n - 2)
						continue;
					double[] binomial = generateBinomialDistribution(p, n,
							shifting);
					for (int xmin : xmins) {
						double[] xMinDistr = Arrays.copyOf(x, xmin);
						double[] binomialExt = ArraysExt.merge(binomial,
								ArraysExt.rep(0.0, x.length - binomial.length));

						double dist = distributionDistance(xmin, x,
								binomialExt, DISTANCE_TYPE.KS_DISTANCE);
						if (dist < minDist) {
							minDist = dist;
							minXmin = xmin;
							xMinDistribution = xMinDistr;
							minP = p;
							minN = n;
							minShifting = shifting;
						}
					}
				}
			}
		}
		// double[] minBinomial = generateBinomialDistribution(minP, minN,
		// minShifting);
		// minBinomial = Arrays.copyOfRange(minBinomial, minXmin,
		// minBinomial.length);
		// minBinomial = ArraysExt
		// .scaleBy(minBinomial, ArraysExt.sum(minBinomial));
		// ArraysExt.print(cdf(minBinomial));
		// double[] empirical = Arrays.copyOfRange(x, minXmin, x.length);
		// empirical = ArraysExt.scaleBy(empirical, ArraysExt.sum(empirical));
		// ArraysExt.print(cdf(empirical));
		return new BinomialParameters(minXmin, xMinDistribution, minP, minN,
				minShifting, minDist);
	}