Recovering a two-value mix from its target average
When each entry is one of two known values and you know the count and the average, the total pins down how many entries take each value.
Setting up the problem
Imagine ten entries, each equal to either 20 or 50, with an average of 38. The question is how many of each. The average alone does not answer it, but the average together with the count does, because the average times the count gives the total. Ten entries at an average of 38 must total 380. With only two possible values, there is exactly one split of ten entries that reaches that total, if any split does. This worksheet finds it by starting from the cheapest case and swapping entries up.
Starting from all low entries
If all ten entries were 20, the total would be 200. The target is 380, so the gap is 380 minus 200, which the basic calculator gives as 180. That gap is how much extra the mix needs. It serves as a baseline and keeps the problem to one unknown. Starting from the high value instead would work equally well, with swaps in the other direction. The all-low reference is convenient because every swap adds a positive amount. The same logic can be run from the top: ten entries of 50 total 500, the target is 120 below that, and each swap to 20 removes 30, so four swaps are needed. The answer of four entries at 20 and six at 50 is identical, and doing the calculation from both ends is a cheap cross-check on your arithmetic.
Counting the swaps
Replacing one 20 with a 50 raises the total by 30. The number of replacements is the gap divided by that step: 180 divided by 30 is 6 on the basic calculator. So six entries are 50 and four remain 20. As a check, 6 times 50 is 300, 4 times 20 is 80, and the sum is 380. A general formula follows. With n entries, low value L, high value H and target average T, the number of high entries is n times (T minus L) divided by (H minus L). For this example, 10 times 18 divided by 30 is 6.
Confirming with the weighted average
The Weighted average calculator turns the answer into a check. Enter the values 20 and 50 with weights 4 and 6, the counts of each. It returns a weighted mean of 38 and a total weight of 10. The mean matches the target and the weight matches the number of entries. This confirms the counts without redoing the algebra. The weights here are counts, which is the case where a weighted average is the same as the plain average of all ten entries.
A second example with different values
Eight entries, each 4 or 10, with an average of 7. The total is 56. All low entries give 32, leaving a gap of 24. Each swap adds 6, so there are 4 swaps. Four entries are 10 and four are 4. The formula agrees: 8 times (7 minus 4) divided by (10 minus 4) is 24 divided by 6, which is 4. The target 7 is the midpoint of 4 and 10, so an even split is what you expect. Midpoints are a quick sanity check: if the target is halfway between the two values, the entries split evenly.
Reading the answer as a proportion
The count of high entries is a share of the total count, and the share comes straight from where the target sits between the two values. The target 38 is 18 above the low value 20, and the two values are 30 apart, so the target is 18 out of 30 of the way up, which is 0.6. The basic calculator returns 0.6 for 18 divided by 30. Applying that share to ten entries gives six high entries and four low ones. The share view is useful because it does not depend on the count: any number of entries with a mean of 38 must have 60 percent of them at 50 and 40 percent at 20, though the count has to make those shares whole.
When the answer is not a whole number
Try ten entries of 20 or 50 with an average of 36. The total is 360, the gap is 160, and 160 divided by 30 is 5.333. A count of five and one third entries makes no sense. No mix of ten entries produces that average. Rounding to five or six entries gives averages of 35 or 38, and neither is 36. Do not round a fractional count and claim the target average still holds. A fractional answer means the data are inconsistent with the stated count and values, or that more than two values are involved. If the count is flexible, you can look for the nearest count that works. Because the high share for a target of 36 is 16 out of 30, or 8 out of 15, only multiples of 15 entries give whole numbers: 15 entries would need 8 at 50 and 7 at 20, which total 400 plus 140, or 540, and average 36.
Targets outside the possible range
The average of entries drawn from 20 and 50 must lie between 20 and 50. A target of 55 is impossible, because even ten entries of 50 average only 50. The formula flags this: a target above the high value produces more high entries than the total count. A target below 20 produces a negative count. Before computing, compare the target with the two values. If it is outside, the problem has no solution, and the error is in the inputs and not in the arithmetic. The endpoints themselves are valid targets: an average of 20 means all entries are 20, and an average of 50 means all are 50, which the formula reproduces with counts of zero and ten.
Where this reasoning is used
The method is known as alligation in older arithmetic texts, where it solved problems of mixing goods at two prices to reach a target price. The same structure appears in blending solutions of two concentrations, grading problems where scores come from two levels, and inventory problems with two unit prices. In each case the unknown is a proportion, and the proportion is fixed by where the target sits between the two values. The distance from the target to the low value, divided by the distance between the two values, is the share that must be high.
Reproduce the checks
Required increase over all-low entries
Open the Basic calculator and enter:
- First number
380- Operation
subtract- Second number
200
Expected output:
Result
180The all-low reference supplies a baseline.
Number of replacements
Open the Basic calculator and enter:
- First number
180- Operation
divide- Second number
30
Expected output:
Result
6Each replacement adds thirty.
Weighted-mean check
Open the Weighted average calculator and enter:
- Values
20,50- Weights
4,6
Expected output:
Weighted average
38Total weight
10The recovered counts satisfy the original target.
References and implementation scope
The examples describe the behavior of the linked Computandum tools. A successful local check does not establish that another application accepts the same format or applies the same limits.