Previous Up Next

7.1.11  Frequencies: frequencies frequences

Given a list of numbers, the frequencies (or frequences) command will return the numbers in the list with their frequencies; i.e., the fraction of list items equal to the number. For example,

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

will return

[[1,0.4],[2,0.3],[3,0.2],[4,0.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, you can enter

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

and you might get

[[0,0.513],[1,0.487]]

Previous Up Next