| |
- _DictWrapper(__builtin__.object)
-
- Hist
- Pmf
class Hist(_DictWrapper) |
|
Represents a histogram, which is a map from values to frequencies.
Values can be any hashable type; frequencies are integer counters. |
|
- Method resolution order:
- Hist
- _DictWrapper
- __builtin__.object
Methods defined here:
- Copy(self, name=None)
- Returns a copy of this Hist.
Args:
name: string name for the new Hist
- Freq(self, x)
- Gets the frequency associated with the value x.
Args:
x: number value
Returns:
int frequency
- Freqs(self)
- Gets an unsorted sequence of frequencies.
- IsSubset(self, other)
- Checks whether the values in this histogram are a subset of
the values in the given histogram.
- Subtract(self, other)
- Subtracts the values in the given histogram from this histogram.
Methods inherited from _DictWrapper:
- GetDict(self)
- Gets the dictionary.
- Incr(self, x, term=1)
- Increments the freq/prob associated with the value x.
Args:
x: number value
term: how much to increment by
- Items(self)
- Gets an unsorted sequence of (value, freq/prob) pairs.
- MaxLike(self)
- Returns the largest frequency/probability in the map.
- Mult(self, x, factor)
- Scales the freq/prob associated with the value x.
Args:
x: number value
factor: how much to multiply by
- Print(self)
- Prints the values and freqs/probs in ascending order.
- Remove(self, x)
- Removes a value.
Throws an exception if the value is not there.
Args:
x: value to remove
- Render(self)
- Generates a sequence of points suitable for plotting.
Returns:
tuple of (sorted value sequence, freq/prob sequence)
- Set(self, x, y=0)
- Sets the freq/prob associated with the value x.
Args:
x: number value
y: number freq or prob
- Total(self)
- Returns the total of the frequencies/probabilities in the map.
- Values(self)
- Gets an unsorted sequence of values.
Note: one source of confusion is that the keys in this
dictionaries are the values of the Hist/Pmf, and the
values are frequencies/probabilities.
- __init__(self, d=None, name='')
Data descriptors inherited from _DictWrapper:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class Pmf(_DictWrapper) |
|
Represents a probability mass function.
Values can be any hashable type; probabilities are floating-point.
Pmfs are not necessarily normalized. |
|
- Method resolution order:
- Pmf
- _DictWrapper
- __builtin__.object
Methods defined here:
- Copy(self, name=None)
- Returns a copy of this Pmf.
Args:
name: string name for the new Pmf
- Exp(self)
- Exponentiates the probabilities.
- Log(self)
- Log transforms the probabilities.
- Mean(self)
- Computes the mean of a PMF.
Returns:
float mean
- Normalize(self, fraction=1.0)
- Normalizes this PMF so the sum of all probs is 1.
Args:
fraction: what the total should be after normalization
- Prob(self, x, default=0)
- Gets the probability associated with the value x.
Args:
x: number value
default: value to return if the key is not there
Returns:
float probability
- Probs(self)
- Gets an unsorted sequence of probabilities.
- Random(self)
- Chooses a random element from this PMF.
Returns:
float value from the Pmf
- Var(self, mu=None)
- Computes the variance of a PMF.
Args:
mu: the point around which the variance is computed;
if omitted, computes the mean
Returns:
float variance
Methods inherited from _DictWrapper:
- GetDict(self)
- Gets the dictionary.
- Incr(self, x, term=1)
- Increments the freq/prob associated with the value x.
Args:
x: number value
term: how much to increment by
- Items(self)
- Gets an unsorted sequence of (value, freq/prob) pairs.
- MaxLike(self)
- Returns the largest frequency/probability in the map.
- Mult(self, x, factor)
- Scales the freq/prob associated with the value x.
Args:
x: number value
factor: how much to multiply by
- Print(self)
- Prints the values and freqs/probs in ascending order.
- Remove(self, x)
- Removes a value.
Throws an exception if the value is not there.
Args:
x: value to remove
- Render(self)
- Generates a sequence of points suitable for plotting.
Returns:
tuple of (sorted value sequence, freq/prob sequence)
- Set(self, x, y=0)
- Sets the freq/prob associated with the value x.
Args:
x: number value
y: number freq or prob
- Total(self)
- Returns the total of the frequencies/probabilities in the map.
- Values(self)
- Gets an unsorted sequence of values.
Note: one source of confusion is that the keys in this
dictionaries are the values of the Hist/Pmf, and the
values are frequencies/probabilities.
- __init__(self, d=None, name='')
Data descriptors inherited from _DictWrapper:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
| |