user14132: Let's say I have 50 addresses which have an average of 0.5 BTC. Some have two or three times the average balance, while others have less than 0.1% of the average. Many times per day an address is selected to either receive or send some amount of coins, fueling the inequality.
What's an efficient, cost-effective method of rebalancing a large number of addresses such that each contains roughly the average balance?
(Assume the algorithm to select a keypair with which to transact is fixed and cannot be modified for argument sake.)

user12034: Once a day, take the addresses with balances more than some multiple (say, twice) of the average, and create a transaction that sends money to the lowest-value addresses. E.g. let's say the average is 0.5 and call the addresses A-Z:

A: 2.0 BTC
B: 1.5 BTC
C: 1.0 BTC
...[other addresses with under 1 BTC]
X: 0.1 BTC
Y: 0.05 BTC
Z: 0 BTC

Transaction would send from A, B, and C to X, Y, and Z so that each has the same amount (0.775 BTC).

user5406: Another solution might be to rebalance during the regular use of the addresses:
Whenever one of the addresses is selected to spend from, check whether an above average balance would remain.
If that is the case, additionally to the planned transaction, redistribute the excess to underfunded addresses, where excess = remainder - average_balance.
You could pick recipient addresses for the redistribution by performing a greedy algorithm such as for example a knapsack problem solver, optimizing for minimal sum of squared distances from the average over all addresses. You could restrain the number of recipient addresses by only allowing an additional recipient address if all previous recipient addresses will be raised to the average.

14132: <p>Let's say I have 50 addresses which have an average of 0.5 BTC. Some have two or three times the average balance, while others have less than 0.1% of the average. Many times per day an address is selected to either receive or send some amount of coins, fueling the inequality.</p>

<p><strong>What's an efficient, cost-effective method of rebalancing a large number of addresses such that each contains roughly the average balance?</strong></p>

<p>(Assume the algorithm to select a keypair with which to transact is fixed and cannot be modified for argument sake.)</p>
 12034: <p>Once a day, take the addresses with balances more than some multiple (say, twice) of the average, and create a transaction that sends money to the lowest-value addresses. E.g. let's say the average is 0.5 and call the addresses A-Z:</p>

<ul>
<li>A: 2.0 BTC</li>
<li>B: 1.5 BTC</li>
<li>C: 1.0 BTC</li>
<li>...[other addresses with under 1 BTC]</li>
<li>X: 0.1 BTC</li>
<li>Y: 0.05 BTC</li>
<li>Z: 0 BTC</li>
</ul>

<p>Transaction would send from A, B, and C to X, Y, and Z so that each has the same amount (0.775 BTC).</p>
 5406: <p><strong>Another solution might be to rebalance during the regular use of the addresses:</strong></p>

<p>Whenever one of the addresses is selected to spend from, check whether an above average balance would remain.</p>

<p>If that is the case, additionally to the planned transaction, redistribute the <em>excess</em> to underfunded addresses, where <code>excess = remainder - average_balance</code>.</p>

<p>You could pick recipient addresses for the redistribution by performing a greedy algorithm such as for example a knapsack problem solver, optimizing for minimal sum of squared distances from the average over all addresses. You could restrain the number of recipient addresses by only allowing an additional recipient address if all previous recipient addresses will be raised to the average.</p>
