Projecting a Non Negative Vector onto the Simplex
You can try the article Projection Onto A Simplex by Yunmei Chen and Xiaojing Ye (the code from which is available here), or look at any book on Convex Opimization. The "closed formula" involves sorting, and you can find it using Lagrange multipliers (the version for inequality constraints).