A frequency distribution for the outcomes of an experiment. A
frequency distribution records the number of times each outcome of an
experiment has occurred. For example, a frequency distribution could be
used to record the frequency of each word type in a document. Formally,
a frequency distribution can be defined as a function mapping from each
sample to the number of times that sample occurred as an outcome.
Frequency distributions are generally constructed by running a number
of experiments, and incrementing the count for a sample every time it is
an outcome of an experiment. For example, the following code will
produce a frequency distribution that encodes how often each word occurs
in a text:
new empty dictionary
|
|
|
None
|
inc(self,
sample,
count=1)
Increment this FreqDist's count for the given sample. |
source code
|
|
|
None
|
|
int
|
N(self)
Returns:
The total number of sample outcomes that have been recorded by this
FreqDist. |
source code
|
|
int
|
B(self)
Returns:
The total number of sample values (or bins) that have counts greater than zero. |
source code
|
|
list
|
samples(self)
Returns:
A list of all samples that have been recorded as outcomes by this
frequency distribution. |
source code
|
|
list
|
|
int
|
Nr(self,
r,
bins=None)
Returns:
The number of samples with count r. |
source code
|
|
|
|
|
int
|
|
list of float
|
|
|
float
|
|
any or None
|
max(self)
Return the sample with the greatest number of outcomes in this
frequency distribution. |
source code
|
|
|
|
plot(self,
*args,
**kwargs)
Plot samples from the frequency distribution displaying the most
frequent sample first. |
source code
|
|
|
|
tabulate(self,
*args,
**kwargs)
Tabulate the given samples from the frequency distribution
(cumulative), displaying the most frequent sample first. |
source code
|
|
|
|
|
|
|
|
|
|
|
list of any
|
keys(self)
Return the samples sorted in decreasing order of frequency. |
source code
|
|
list of any
|
|
list of tuple
|
items(self)
Return the items sorted in decreasing order of frequency. |
source code
|
|
iter
|
|
iter
|
|
iter
|
|
iter of any
|
|
FreqDist
|
|
|
None
|
update(self,
samples)
Update the frequency distribution with the provided list of samples. |
source code
|
|
|
v, remove specified key and return the corresponding value
|
pop(self,
other)
If key is not found, d is returned if given, otherwise KeyError is
raised |
source code
|
|
|
(k, v), remove and return some (key, value) pair as a
|
|
|
None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string
|
|
|
string
|
|
|
|
|
|
Inherited from dict:
__cmp__,
__contains__,
__delitem__,
__getattribute__,
__hash__,
__len__,
__new__,
fromkeys,
get,
has_key,
setdefault
|