Previous Up Next

9.1.12  Frequencies: frequencies frequences

The frequency of a number in a list is the fraction of the list equal to the number. The frequencies command finds the frequencies of the numbers in a list.
frequences is a synonym for frequencies.


Example.
Input:

frequencies([1,2,1,1,2,1,2,4,3,3])

Output:





10.4
20.3
30.2
40.1





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:
Input:

frequencies([rand(2) $ (k=1..1000)])

Output (for example):



00.484
10.516


(See Section 9.3.1 for information on rand.)


Previous Up Next