Projection of a Symmetric Matrix onto the Matrix Probability Simplex The definition of probability simplex in $\mathbb{S}^n$:   
$$\{X\in \mathbb{S}^n: X\geq 0, \text{tr}(X) = 1\},$$ where $\mathbb{S}^n$ is the vector space of symmetric $n\times n$ matrices.     
A symmetric matrix $A\in \mathbb{S}^n$ has a diagonalization:  
$$A = U\Lambda U^T$$  
By the property of "trace of a matrix", we have:   
$$\text{tr}(A) = \text{tr}(\Lambda)$$  
So I think the projection of $A$ onto the probability simplex is the following:   


*

*$\pi(A) = U\Lambda^+U^T$, where $\Lambda^T$ is defined as:
$$\lambda_i'=\lambda_i, \text{ for } \lambda_i\geq 0 \\ \lambda_i' = -\lambda_i, \text{ for } \lambda_i< 0$$   


Note: $\pi()$ is the projection onto the probability simplex

My question is how to satisfy the condition of the unity trace?

 A: There is no closed form solution I'm aware of.
But using Orthogonal Projection onto the Intersection of Convex Sets you will be able to take advantage of the simple projection to each set by itself.
So formulaitng the problem:
$$\begin{aligned}
\arg \min_{X} \quad & \frac{1}{2} {\left\| X - Y \right\|}_{F}^{2} \\
\text{subject to} \quad & X \in \mathcal{S}_{1} \bigcap \mathcal{S}_{2} \bigcap \mathcal{S}_{3} \\ 
\end{aligned}$$
Where $ \mathcal{S}_{1} $ is the set of Symmetric Matrices ($ \mathbb{S}^{n} $), $ \mathcal{S}_{2} $ is the set of matrices with non negative elements and $ \mathcal{S}_{3} $ is the set of matrices with a trace of value 1.
The projection to each is given by:

*

*Symmetric: $ \frac{Y + {Y}^{T}}{2} $.

*Non Negative: $ {Y}_{i, j} = \max({Y}_{i, j} ,0) $.

*Trace of Value 1: $ \operatorname{Diag} \left( Y \right) = \operatorname{Diag} \left( Y \right) - \frac{ \operatorname{Trace}(Y) - 1 }{n} $.

I wrote a MATLAB Code which implements the above in the framework linked. The code is accessible in my StackExchange Mathematics Q1909139 GitHub Repository.
Remark:
The code doesn't assume $ Y $ is a symmetric matrix. If it does, since the other 2 projections don't ruin symmetry the projection onto symmetric matrix isn't required.
