|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.util.Distribution
Immutable class for representing normalized, smoothed discrete distributions
from Counters
. Smoothed counters reserve probability mass for unseen
items, so queries for the probability of unseen items will return a small
positive amount. #totalCount
should always return 1.
Counter passed in constructors is copied.
Method Summary | |
static Distribution |
addOneSmoothedCounter(Counter counter,
int numberOfKeys)
Creates an add-1 smoothed Distribution from the given counter, ie adds one count to every item, including unseen ones, and divides by the total count. |
Object |
argmax()
|
boolean |
containsKey(Object key)
|
static Distribution |
distributionFromLogisticCounter(Counter cntr)
Maps a counter representing the linear weights of a multiclass logistic regression model to the probabilities of each class. |
boolean |
equals(Object o)
|
double |
getCount(Object key)
Returns the current count for the given key, which is 0 if it hasn't been seen before. |
int |
getNumberOfKeys()
|
double |
getReservedMass()
|
static Distribution |
goodTuringSmoothedCounter(Counter counter,
int numberOfKeys)
Creates a Good-Turing smoothed Distribution from the given counter. |
int |
hashCode()
|
static Distribution |
jeffreysPerksSmoothedCounter(Counter counter,
int numberOfKeys)
Creates a smoothed Distribution using the Jeffreys-Perks law, ie adds one half count to every item, including unseen ones, and divides by the total count. |
Set |
keySet()
|
static Distribution |
lidstoneSmoothedCounter(Counter counter,
int numberOfKeys,
double lambda)
Creates a smoothed Distribution using Lidstone's law, ie adds lambda (typically between 0 and 1) to every item, including unseen ones, and divides by the total count. |
static void |
main(String[] args)
For internal testing purposes only. |
static Distribution |
normalizedCounter(Counter counter)
Creates a Distribution from the given counter, ie makes an internal copy of the counter and divides all counts by the total count. |
static Distribution |
normalizedCounterWithDirichletPrior(Counter c,
Distribution prior,
double weight)
Returns a Distribution that uses prior as a Dirichlet prior weighted by weight. |
double |
probabilityOf(Object key)
Returns the normalized count of the given object. |
String |
toString()
|
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Method Detail |
public String toString()
public double getReservedMass()
public int getNumberOfKeys()
public Set keySet()
public boolean containsKey(Object key)
public double getCount(Object key)
get
that casts
and extracts the primitive value.
public static Distribution normalizedCounter(Counter counter)
counter
-
public static Distribution addOneSmoothedCounter(Counter counter, int numberOfKeys)
counter
- numberOfKeys
-
public static Distribution jeffreysPerksSmoothedCounter(Counter counter, int numberOfKeys)
counter
- numberOfKeys
-
public static Distribution lidstoneSmoothedCounter(Counter counter, int numberOfKeys, double lambda)
counter
- numberOfKeys
- lambda
-
public static Distribution goodTuringSmoothedCounter(Counter counter, int numberOfKeys)
counter
- numberOfKeys
-
public static Distribution normalizedCounterWithDirichletPrior(Counter c, Distribution prior, double weight)
c
- prior
- weight
- average "pseudo-count" of Objects in prior
public static Distribution distributionFromLogisticCounter(Counter cntr)
public double probabilityOf(Object key)
key
-
public Object argmax()
public boolean equals(Object o)
public int hashCode()
public static void main(String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |