private static void smoothCountsAndCalculateLogProbs(int[][] beginTrigramCounts,
			int[][] endTrigramCounts, int[][][] trigramCounts, long totalTrigrams) {

		// Smooth for non-existing trigrams
		for (int i = 0; i < ASCII_CHAR_COUNT; i++) {

			for (int j = 0; j < ASCII_CHAR_COUNT; j++) {

				if (beginTrigramCounts[i][j] == 0) {
					beginTrigramCounts[i][j] = 1;
					totalTrigrams++;
				}

				if (endTrigramCounts[i][j] == 0) {
					endTrigramCounts[i][j] = 1;
					totalTrigrams++;
				}

				for (int k = 0; k < ASCII_CHAR_COUNT; k++) {
					if (trigramCounts[i][j][k] == 0) {
						trigramCounts[i][j][k] = 1;
						totalTrigrams++;
					}
				}
			}
		}

		double[][] beginLogTrigrams = logProbs.getBeginLogTrigrams();
		double[][] endLogTrigrams = logProbs.getEndLogTrigrams();
		double[][][] logTrigrams = logProbs.getLogTrigrams();

		// Now calculate log probabilities
		for (int i = 0; i < ASCII_CHAR_COUNT; i++) {

			for (int j = 0; j < ASCII_CHAR_COUNT; j++) {
				beginLogTrigrams[i][j] =
					Math.log10((double) beginTrigramCounts[i][j] / (double) totalTrigrams);
				endLogTrigrams[i][j] =
					Math.log10((double) endTrigramCounts[i][j] / (double) totalTrigrams);

				for (int k = 0; k < ASCII_CHAR_COUNT; k++) {
					logTrigrams[i][j][k] =
						Math.log10((double) trigramCounts[i][j][k] / (double) totalTrigrams);
				}
			}
		}
	}
Smooth any 0-count entries and calculate log probabilities

@param beginTrigramCounts
@param endTrigramCounts
@param trigramCounts
@param totalTrigrams
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/string/NGramUtils.java