# Algorithm (discfreqs)

The data consists of a sample of n observations of a discrete variable, denoted by$x_i\,\!$, fori=1,...,n. Then sort the data ascending, the ordered data is denoted by$x_{(i)}\,\!$, fori=1,...,n. The corresponding count of the value $x_{(i)}\,\!$ is denoted by$c_i\,\!$, , which is the frequency of the ith value. The relative frequency and cumulative frequency of $x_{(i)}\,\!$ are calculated as follows:

$RelativeFrequency=c_k/n\,\!$ and $CumulativeFrequency_k=\sum_{k=1}^N{c_i}/n\,\!$, for k=1,...,n.