public class SmoothingUtils
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
private |
SmoothingUtils()
A private constructor since this class should never be instantiated.
|
Modifier and Type | Method and Description |
---|---|
static void |
addFrequency(java.util.Map<java.lang.Integer,java.lang.Integer> frequencyCounts,
int frequency)
Add one to the count of the given frequency in the given Map.
|
private static double |
getFrequencyCountEstimate(double[] regression,
int frequency)
Get the frequency count estimate of the given frequency based on the values from the regression
from a log-log plot.
|
static java.util.Map<java.lang.Integer,java.lang.Integer> |
getFrequencyMap(java.util.Collection<java.lang.Integer> counts)
Get the frequency counts of the counts in the given Collection.
|
static java.util.Map<java.lang.Integer,java.lang.Double> |
getGoodTuringSmoothing(java.util.Map<java.lang.Integer,java.lang.Integer> frequencyCounts,
int count)
Return the Good-Turing smoothed probability values for our counts.
|
static int |
getTotalCount(java.util.Collection<java.lang.Integer> counts)
Get the sum of the counts in the given collection.
|
private static double[] |
linearRegression(double[] x,
double[] y)
Perform linear regression given x and y coordinates.
|
static void |
removeFrequency(java.util.Map<java.lang.Integer,java.lang.Integer> frequencyCounts,
int frequency)
Remove one count from the given frequency in the given Map.
|
private SmoothingUtils()
public static java.util.Map<java.lang.Integer,java.lang.Double> getGoodTuringSmoothing(java.util.Map<java.lang.Integer,java.lang.Integer> frequencyCounts, int count)
frequencyCounts
- A Map of the frequency of an object to the number of objects with that frequency.count
- The total count of all objects.private static double getFrequencyCountEstimate(double[] regression, int frequency)
regression
- The slope (index 0) and intercept (index 1) of the regression line (from a
log-log plot).frequency
- The frequency whose count we want.private static double[] linearRegression(double[] x, double[] y)
x
- The x coordinates of our points.y
- The y coordinates of our points.public static void removeFrequency(java.util.Map<java.lang.Integer,java.lang.Integer> frequencyCounts, int frequency)
frequencyCounts
- A Map of the frequency of an object to the number of objects with that frequency.
We will decrement 1 from this Map.frequency
- The frequency whose count we want to decrement.public static void addFrequency(java.util.Map<java.lang.Integer,java.lang.Integer> frequencyCounts, int frequency)
frequencyCounts
- A Map of the frequency of an object to the number of objects with that frequency.
We will increment one in this Map.frequency
- The frequency whose count we want to increment.public static java.util.Map<java.lang.Integer,java.lang.Integer> getFrequencyMap(java.util.Collection<java.lang.Integer> counts)
counts
- The Collection whose frequency counts we want.public static int getTotalCount(java.util.Collection<java.lang.Integer> counts)
counts
- A Collection of counts which we want to sum.