in reply to Grouping numbers

How optimal do your groupings need to be? And what do you consider to be optimal?

For example, in the following set of numbers, those algorithms that start a new group when adding the next value causes the current grouping to break the limit would group the first two values, 122.45 & 122.55 in a group by themselves as adding the third value, 122.67 causes the first value to be outside the lower boundary. The next five values can then form a second group.

However, isolating that first value into it's own group, allows the next 4 values to become a group, leaving the last two as a third group.

Not well demonstrated, trying to come up with a good demonstration is labourious, but it is possible to see that sometimes it will be better to drop the first value from a grouping rather than the last added in order to incorporate as many values as possible into a group.

Hence the questions at the top. Possibilities for optimal might be

values 2 3 4 5 6 7 122.35 122.517 122.455 122.488 122.483 122.533 low limit 122.45 122.5 122.55 122.567 122.605 122.67 122.638 122.633 122.75 122.683 122.77 122.79 122.80 122.65 122.817 122.755 122.788 122.783 122.833 high limit

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.