I've been banging my head on this one all day! I'm going to do my best to explain the problem, but bear with me.
Given a set of numbers $S = \{X_1, X_2, \dots, X_n\}$ and a scalar $T$, where it is guaranteed that there is at least one member of $S$ that is less than $T$ and at least one member that's greater than $T$,
I'm looking for an algorithm to create a Convex Combination of these scalars that equals $T$.
For example, for the set $\{2,4\}$ and the scalar $3$, the answer is:
$.5 \cdot 2 + .5 \cdot 4 = 3.$
I believe in many cases there are infinite infinitely many solutions.
I'm looking for a generalized algorithm/formula to find these coefficients.
Additionally, I would like for the coefficient weights to be distributed as evenly as possible (of course while still adding up to 1.) For instance, for the set $\{1,2,4\}$ and the scalar $3$, a technically valid solution would be the same as the first example but with the coefficient for $1$ assigned a weight of 0 - but it would be prefferable to assign a non-zero weight. I may not be thinking through this last part very clearly :)