20.1.12 Frequencies
The frequency of a number in a list is the fraction of the list equal
to the number. The frequencies
or frequences
command finds the frequencies of the numbers in a list.
-
frequencies takes
L, a list of numbers.
- frequencies(L) returns a list whose elements are
the numbers in the list and their frequencies.
Example
frequencies([1,2,1,1,2,1,2,4,3,3]) |
You can use this, for example, to simulate flipping a fair coin and
seeing how many times each side appears; to flip a coin 1000 times,
for example:
frequencies([rand(2)$(k=1..1000)]) |
(See Section 20.3.2 for information on rand.)