An base class for generation an object contains a dictionary.
@Params:
param | type | description |
---|---|---|
values | string | array |
name | string | sequence of values |
@Methods:
Initializes with a sequence of equally-likely values.
@Params:
param | type | description |
---|---|---|
values | array | sequence of values |
Initializes with a map from value to probability.
@Params:
param | type | description |
---|---|---|
values | map | map from value to probability |
Initializes with a Pmf.
@Params:
param | type | description |
---|---|---|
values | pmf | Pmf object |
Throw an error.
Gets an unsorted sequence of values.
Note: One source of confusion is that the keys of this
dictionary are the values of the Hist/Pmf, and the
values of the dictionary are frequencies/probabilities.
Gets an unsorted sequence of (value, freq/prob) pairs.
Sets the freq/prob associated with the value x.
@Params:
param | type | description |
---|---|---|
value | any | number value or case name |
prob | number | number freq or prob |
Increments the freq/prob associated with the value x.
@Params:
param | type | description |
---|---|---|
x | any | number value or case name |
term | number | how much to increment by |
Scales the freq/prob associated with the value x.
@Params:
param | type | description |
---|---|---|
x | any | number value or case name |
factor | number | how much to multiply by |
Removes a value.
Throws an exception if the value is not there.
@Params:
param | type | description |
---|---|---|
value | any | value to remove |
Returns the total of the frequencies/probabilities in the map.
Returns the largest frequency/probability in the map.
Returns a copy.
Make a shallow copy of d. If you want a deep copy of d,
use one method to deep clone the whole object.
@Params:
param | type | description |
---|---|---|
name | string | string name for the new Hist |
@Returns: new object
Multiplies the values by a factor.
@Params:
param | type | description |
---|---|---|
factor | number | what to multiply by |
@Returns: new object
Log transforms the probabilities.
Removes values with probability 0.
Normalizes so that the largest logprob is 0.
@Params:
param | type | description |
---|---|---|
m | number | how much to shift the ps before exponentiating |
Exponentiates the probabilities.
If m is un-exist, normalizes so that the largest prob is 1.
@Params:
param | type | description |
---|---|---|
m | number | how much to shift the ps before exponentiating |
Gets the dictionary.
Sets the dictionary.
@Params:
param | type | description |
---|---|---|
d | map | object |
Generates a sequence of points suitable for plotting.
@Returns: array of [sorted value sequence, freq/prob sequence]
Prints the values and freqs/probs in ascending order.
@Params:
param | type | description |
---|---|---|
indent |