Say I have the following Least Squares equation with constraints and constant parameters $a_i$:
$\min(\sum(x_{i}-a_{i})^2), \sum{x_{i}}=1,x_i>0$
Basically, I am looking for the best set of $x_i$'s to minimise this function while ensuring their sum equals 1. I am not trying to model any data, so it is not a traditional use-case.
Is there an analytical solution to this problem? Or do I have to look at quadratic programming or iterative approaches? If so, any pointers? I haven't been able to work anything out myself.
I do not need a perfect solution, so some reasonable algorithmic estimate is sufficient.
If your vector $x$ has $n$ components, then simply set all $x_i:=\frac{1}{n}$. Then $\bar{x}=\frac{1}{n}$, each $x_i$ is equal to this mean, your sum of squares is zero (so it is minimal, because anything else would be greater than zero), and your constraints are satisfied.
And I agree with Dave that this would be a better fit for Math.SE.