I have the following problem which might seem simple.
I would be happy if you could help me with it.

There is a list of values such as..

100.20
100.23
100.35
122.45
122.55
122.67
122.75
145.88
145.97
146.01
146.10
etc.

As you can see some of the values are close to each other those values that are close to each other have to be grouped into groups so that the difference of a values to the average value is not greater then a value X.
For example: X=0.15

group1: Average:100.26
100.20 dif=0.06
100.23 dif=0.03
100.35 dif=0.09

group2: Average:122.60
122.56 dif=0.04
122.67 dif=0.03
122.74 dif=0.14

Outlier: 122.43 since dif=0.17>X

group3: Average:145.99
145.88 dif=0.11
145.97 dif=0.02
146.01 dif=0.02
146.10 dif=0.11

Thank you for any help that you could give me with this.

In reply to Grouping numbers by tamaguchi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.