public class SimpleGoodTuring
extends java.lang.Object
Constructor and Description |
---|
SimpleGoodTuring(int[] r,
int[] n)
Each instance of this class encapsulates the computation of the smoothing
for one probability distribution.
|
Modifier and Type | Method and Description |
---|---|
double[] |
getProbabilities()
Returns the probabilities allocated to each type, according to their count
in the underlying collection.
|
double |
getProbabilityForUnseen()
Returns the probability allocated to types not seen in the underlying
collection.
|
static void |
main(java.lang.String[] args)
Like Sampson's SGT program, reads data from STDIN and writes results to
STDOUT.
|
public SimpleGoodTuring(int[] r, int[] n)
public double getProbabilityForUnseen()
public double[] getProbabilities()
public static void main(java.lang.String[] args) throws java.lang.Exception
1 10 2 6 3 4 5 2 8 1This represents a collection in which 10 types occur once each, 6 types occur twice each, 4 types occur 3 times each, 2 types occur 5 times each, and one type occurs 10 times, for a total count of 52. This input will produce the following output:
r n p p* ---- ---- ---- ---- 0 0 0.000 0.1923 1 10 0.01923 0.01203 2 6 0.03846 0.02951 3 4 0.05769 0.04814 5 2 0.09615 0.08647 8 1 0.1538 0.1448The last column represents the smoothed probabilities, and the first item in this column represents the probability assigned to unseen items.
java.lang.Exception