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
- Smallest number of groups
- Biggest group sizes.
- Even group sizes.
- Quickest to calculate (that doesn't place each value in a separate group :)
- Other?
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.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.