public static Double calcLogSumOfLogs(Double logX, Double logY) {		
		if (logX == null && logY == null) {
			return null;
		} else if (logX == null) {
			return logY;
		} else if (logY == null) {
			return logX;
		}

		if (logX >= 0 || logY >= 0) {
			double x = Math.pow(2, logX);
			double y = Math.pow(2, logY);

			double logSum = Math.log(x + y) / Math.log(2);
			return logSum;
		}

		double logZ = Math.max(logX, logY) * -1.0;
		double scaledLogX = logX + logZ;
		double scaledLogY = logY + logZ;

		double scaledX = Math.pow(2, scaledLogX);
		double scaledY = Math.pow(2, scaledLogY);

		double logScaledSum = Math.log(scaledX + scaledY) / Math.log(2);
		double logSum = logScaledSum - logZ;
		
		if (!(Double.isNaN(logX) || Double.isNaN(logY))) {
			System.out.println("logX = " + logX + ", logY = " + logY + ", logSum = " + logSum);
		}

		return logSum;
	}