Suppose a random positive definite matrix $A\in\mathbb{R}^{n\times n}$ has density function (with respect to the lebesgue measure on $\mathbb{R}^{n(n+1)/2}$) $f(A)=g(\lambda\_1(A),...,\lambda\_n(A))$ where $g$ is a function invariant under permutation of coordinates and $\lambda\_1(A),...,\lambda\_n(A)>0$ are eigenvalues of $A$, i.e. the density of $A$ only depends on its spectrum. Examples include [Wishart distribution](https://en.wikipedia.org/wiki/Wishart_distribution) (with identity covariance), [matrix beta distribution](https://en.wikipedia.org/wiki/Matrix_variate_beta_distribution), etc.


Now, we construct another random matrix in the following way: first generate a diagonal matrix $\Lambda$ such that the joint distribution of the diagonal elements is the same as the joint distribution of the eigenvalues of $A$; second we generate an orthogonal matrix $P\in O(n)$ uniformly and INDEPENDENT of $\Lambda$; then we set $B=P\Lambda P^T$.


Now my question is that is the distribution of $B$ the same as the distribution of $A$? If it is true, how do we prove it? It seems obvious but I do not know how to rigorously justify it. 


Update:
Thank @Iosif Pinelis for giving an counter example! A further question is that, do the diagonal elements of $B$ have the same distribution as $A$'s diagonal elements?



Density of random matrix only depends on its spectrum
$\newcommand{\tr}{\operatorname{\mathrm tr}}
\newcommand{\R}{\mathbb{R}}
$
The answer is (of course) no (because the Lebesgue measure on the set $\mathbb{R}^{n(n+1)/2}$ of all possible vectors corresponding to on-and-above-diagonal part of the symmetric matrix $A$ has little to do with with the spectrum of the matrix $A$). 


E.g., let $n=2$ and write $A=\begin{bmatrix}a&b\\b&c\end{bmatrix}$. The condition that $A$ is positive definite means exactly that $\tr A=a+c>0$ and $\det A=ac-b^2>0$. Suppose that 
\begin{equation}
 f(A)=f\_A(a,b,c):=kI\{0<\tr A<1,\det A>0\}=kI\{0<a+c<1,b^2<ac\},
\end{equation}
where $I$ denotes the indicator and 
$k:=\frac{12}\pi$, 
the normalizing factor that makes $f$ a probability density with respect to the Lebesgue measure on the set $\mathbb{R}^{2(2+1)/2}=\mathbb{R}^3$ of all triples $(a,b,c)$. Moreover, $f$ depends on $A$ only through the spectrum of $A$.


The expected value of the product of the diagonal entries $a,c$ of $A$ is 
\begin{equation}
 EA\_{11}A\_{22}=\iiint\limits\_{\R^3}ac f\_A(a,b,c)\,da\,dc\,db=\frac9{80}. 
\end{equation}


We may write the orthogonal random matrix $P$ as $R\_T$, where $T$ is independent of $A$ and uniformly distributed in the interval $[0,2\pi)$, and $R\_t=\begin{bmatrix}\cos t&-\sin t\\\sin t&\cos t\end{bmatrix}$. The product of the diagonal entries of $B=R\_T\Lambda R\_T'$ is 
\begin{equation}
 B\_{11}B\_{22}=\tfrac18\, [a^2+c^2 - b^2 + 6 a c - ((a-c)^2+ b^2) \cos4 t]. 
\end{equation}
Hence, 
\begin{align}
 EB\_{11}B\_{22}&=\int\_0^{2\pi}\frac{dt}{2\pi}\iiint\limits\_{\R^3}B\_{11}B\_{22} f\_A(a,b,c)\,da\,dc\,db =\frac{81}{640}\ne\frac9{80}=EA\_{11}A\_{22}. 
\end{align}
Thus, (the diagonal entries of) the random matrices $A$ and $B$ are not equal in distribution. 


