# clustering data on a spectrum with a custom distance function

I have recently been faced with a problem on spectral analysis which may find a solution with data clustering techniques. I have an energy spectrum with around 200 energy levels: many of them separated by less or comparable to the error on energy, and so I would like to cluster them to consider the levels very close in energy (with respect to their errors) as only one. Data are organised in a table of four columns where the first one is the energy, the second and third are level intensity and its errors (irrelevant for the clustering),and the fourth is the error on energy.

level52 = {
{6430, 0.93, 0.0808, 12},
{6452, 0.56, 0.1120, 13},
{6485, 2.03, 0.0848, 15},
{6531, 0.78, 0.0579, 18},
{6584, 0.56, 0.0488, 21},
{6659, 0.83, 0.0483, 25}
}

etc...

I therefore tried:

FindClusters[Drop[level52, None, {2, 3, 4}] -> level52, 40]

but this does not cluster levels properly.

Does anyone know what it if the appropriate distance method to use in the case ? Is there a way to define a distance function using the error on energy on the fourth column of the table ?

For example a distance which is the difference in energy between the levels divided by the sum of their errors. Many thanks for the help.

• Hi and welcome to Mma.SE. Start by taking the tour now and learning about asking and what's on-topic. Always edit if improvable, show due diligence, give brief context, include minimal working example of code and data in formatted form. By doing all this you help us to help you and likely you will inspire great answers. The site depends on participation, as you receive give back: vote and answer questions, keep the site useful, be kind, correct mistakes and share what you have learned. – rhermans Aug 22 '18 at 16:05
• For the data that you present, what is the expected answer? – bill s Aug 22 '18 at 17:05
• @bill s Hi ! Something like FindClusters[{ {6430, 0.93, 0.0808, 12}, {6452, 0.56, 0.1120, 13}, {6485, 2.03, 0.0848, 15}},\\ first cluster, energies compatible within error {{6531, 0.78, 0.0579, 18}, {6584, 0.56, 0.0488, 21}},\\ second cluster, energies compatible within error {{6659, 0.83, 0.0483, 25}} \\third cluster: energy not compatible within errors with others energies – user59813 Aug 23 '18 at 15:19