class MutableProbDist(ProbDistI): (source)
Constructor: MutableProbDist(prob_dist, samples, store_logs)
An mutable probdist where the probabilities may be easily modified. This simply copies an existing probdist, storing the probability values in a mutable dictionary and providing an update method.
| Method | __init__ |
Creates the mutable probdist based on the given prob_dist and using the list of samples given. These values are stored as log probabilities if the store_logs flag is set. |
| Method | logprob |
Return the base 2 logarithm of the probability for a given sample. |
| Method | max |
Return the sample with the greatest probability. If two or more samples have the same probability, return one of them; which sample is returned is undefined. |
| Method | prob |
Return the probability for a given sample. Probabilities are always real numbers in the range [0, 1]. |
| Method | samples |
Return a list of all samples that have nonzero probabilities. Use prob to find the probability of each sample. |
| Method | update |
Update the probability for the given sample. This may cause the object to stop being the valid probability distribution - the user must ensure that they update the sample probabilities such that all samples have probabilities between 0 and 1 and that all probabilities sum to one. |
| Instance Variable | _data |
Undocumented |
| Instance Variable | _logs |
Undocumented |
| Instance Variable | _sample |
Undocumented |
| Instance Variable | _samples |
Undocumented |
Inherited from ProbDistI:
| Method | discount |
Return the ratio by which counts are discounted on average: c*/c |
| Method | generate |
Return a randomly selected sample from this probability distribution. The probability of returning each sample samp is equal to self.prob(samp). |
| Constant | SUM |
True if the probabilities of the samples in this probability distribution will always sum to one. |
nltk.probability.ProbDistI.__init__Creates the mutable probdist based on the given prob_dist and using the list of samples given. These values are stored as log probabilities if the store_logs flag is set.
| Parameters | |
| prob | the distribution from which to garner the probabilities |
| samples:sequence of any | the complete set of samples |
| store | whether to store the probabilities as logarithms |
nltk.probability.ProbDistI.logprobReturn the base 2 logarithm of the probability for a given sample.
| Parameters | |
| sample:any | The sample whose probability should be returned. |
| Returns | |
| float | Undocumented |
nltk.probability.ProbDistI.maxReturn the sample with the greatest probability. If two or more samples have the same probability, return one of them; which sample is returned is undefined.
| Returns | |
| any | Undocumented |
nltk.probability.ProbDistI.probReturn the probability for a given sample. Probabilities are always real numbers in the range [0, 1].
| Parameters | |
| sample:any | The sample whose probability should be returned. |
| Returns | |
| float | Undocumented |
nltk.probability.ProbDistI.samplesReturn a list of all samples that have nonzero probabilities. Use prob to find the probability of each sample.
| Returns | |
| list | Undocumented |
Update the probability for the given sample. This may cause the object to stop being the valid probability distribution - the user must ensure that they update the sample probabilities such that all samples have probabilities between 0 and 1 and that all probabilities sum to one.
| Parameters | |
| sample:any | the sample for which to update the probability |
| prob:float | the new probability |
| log:bool | is the probability already logged |