@Override
	public double chiSquared(
		final Histogram observation,
		final Distribution hypothesis
	) {
		requireNonNull(observation);
		requireNonNull(hypothesis);

		final var samples = observation.samples();
		if (samples == 0) {
			return Double.POSITIVE_INFINITY;
		}

		final double epsilon = 1.0/samples;
		final var cdf = hypothesis.cdf();

		final var result = observation.buckets().stream()
			.mapToDouble(bucket -> {
				final var e = cdf.probability(bucket.interval())*samples;
				final var o = bucket.count();
				return e > epsilon || o > 1 ? sqr(Math.abs(o - e) - 0.5)/e : 0;
			})
			.sum();

		return Double.isFinite(result) ? result : Double.POSITIVE_INFINITY;
	}
Create a new Yates's chi-squared tester.

@param pValue the p-value used for the hypothesis tester
jenetics.incubator/src/main/java/io/jenetics/incubator/stat/YatesChiSquared.java