|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.stats.SimpleGoodTuring
public class SimpleGoodTuring
Simple Good-Turing smoothing, based on code from Sampson, available at: ftp://ftp.informatics.susx.ac.uk/pub/users/grs2/SGT.c
See also http://www.grsampson.net/RGoodTur.html
Constructor Summary | |
---|---|
SimpleGoodTuring(int[] r,
int[] n)
Each instance of this class encapsulates the computation of the smoothing for one probability distribution. |
Method Summary | |
---|---|
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(String[] args)
Like Sampson's SGT program, reads data from STDIN and writes results to STDOUT. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SimpleGoodTuring(int[] r, int[] n)
Method Detail |
---|
public double getProbabilityForUnseen()
public double[] getProbabilities()
public static void main(String[] args) throws 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.
Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |