Note that there are some explanatory texts on larger screens.

plurals
  1. POFinding a good match of two lists of numbers
    primarykey
    data
    text
    <p>I got two sets of numbers, with <strong>SET2</strong> having more items in it usually. It's guaranteed that the count of <strong>SET2</strong> is equal or greater than the count of <strong>SET1</strong>. Acutally, since the order matters the input are rather lists than sets.</p> <p>My goal is to combine (sum up) / reorder the numbers from <strong>SET2</strong> to make it as similar to <strong>SET1</strong> as possible. I define the similarity as the sum of the deviations at every position. See <a href="https://stackoverflow.com/questions/14480336/more-efficient-way-to-build-sum-than-for-loop/14480404#14480404">this post</a> for the way I calculate the similarity. The smaller the sum, the better. </p> <p>My first approach was to try all combinations and pick the best one. This only works for quite small sets (esp. the second one). See <a href="https://stackoverflow.com/questions/14438404/pool-numbers-in-a-set-of-numbers-to-match-the-size-of-another-set/14440778#14440778">this post</a> and the answer from Rawling. Is there a smarter way to get a good combination? I definitely don't need the best one. A good one would be fine as a result. Obviously a sets with empty subsets are nonsense. Extremly unbalanced sets don't seem to be very promising to me. SET1 tends to have about 8 but can have up to 18 entries. SET2 has often a count of more than 10 (up to 35). The sum of the numbers in the two sets is equal (except for rounding errors). </p> <p>Here is an example with good and bad results (not all possible ones):</p> <pre><code>SET1 = { 272370, 194560, 233430 }; SET2 = { 53407.13, 100000, 365634.03, 181319.07 } 272370 | 194560 | 233430 --------------------------------------------------------------------- 365634.03 | 100000 + 53407.13 | 181319.07 (best match) 365634.03 | 181319.07 | 100000 + 53407.13 (good) 365634.03 | 100000 |181319.07 + 53407.13 (ok) 53407.13 |365634.03 + 100000 | 181319.07 (bad) 53407.13 |365634.03 + 181319.07 | 100000 (bad) . |365634.03 + 181319.07 | 53407.13 + 100000 (invalid) 53407.13 + 100000 |365634.03 + 181319.07 | (invalid) </code></pre> <p>Please let me know if I forgot to describe a premiss or my description is unclear or even faulty. I'm also happy to provide another example. </p> <p>Thanks in advance!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload