# Mode from continuous distribution

I've continuous distribution set of values.

For example:

0, 0.01, 0.012, 1.2, 5.33, 5.24, 5.38, 30.20, 30.21, 30.13, 30.12

I want to calculate most frequent value from this set. So I've found this question which says it's mode.

I've problem with spliting this set into clases.

I want to put in my algorithm some delta value and assign to one class values which fullfills x - delta < mean_class_value < x + delta. Of course I see the problem that I don't have a class and to create it I need it's mean value. Also solution which will make the same reasonable result will be ok.

Any solution in pseudocode will be great help.

My current solution its pseudocode mixed with c++ but hope understandable:

std::vector<std::pair<double, std::vector<elementtype> > > classes;
foreach(element)
{
foreach(class in classes)
{
if(std::abs(element.value - class.first) //class first is value of class
{
//assign element to class here
class.first = (class.first + element.value) / 2.0 //averaging class value
break;
}
else
{
//create new class
}

}
}

-

There are many estimators for the mode of a continuous distribution.

First of all you have discrete set of values . Depending on the purpose of your data analysis you can evaluate different statistics ( functions of the data). If you want to divide your data into classes you should calculate histogram. Assume $x_{(1)}=min_{i} x_i$ ( the smallest element) and $x_{(n)}=max_i x_i$ ( the largest element ), assume also that you want to divide your data set into $k$ disjoint classes. Proceed as follows: let $\delta=\frac{x_{(n)}-x_{(1)}}{k}$, $\forall i=0,...,k-1$ calculate amount of the elements in the interval $[x_{(1)}+i*\delta,x_{(1)} + (i+1)*\delta]$. This will be representation of your data as a histogram, nothing more. As for the most frequent value, I doubt that mode will be of any value ( if you have indeed continuous distribution it won't even have a meaning) instead you should calculate mean.