Phase space derivation of quantum harmonic oscillator partition function I would like to derive the partition function for the quantum Harmonic oscillator from scratch: 
$$\tag{1}  Z = \int dp \, dx\, e^{-\beta H}.$$
The free particle appears in many textbooks.  $H = p^2$ so it is a Gaussian integral
$$\tag{2}  Z = \int dp \, dx \, e^{-\beta p^2} = L \int dp \, e^{-\beta p^2}
= L \sqrt{2\pi/\beta}.$$
I wanted to do the same calculation for the Harmonic oscillator I get could take advantage that 
$$\tag{3}  Z = \int dp \, dx \, e^{-\beta (p^2 + x^2)} = 
 \int  dx \, e^{-\beta  x^2} \cdot \int dp \,  e^{-\beta p^2 } =
\sqrt{2\pi} \cdot \sqrt{2\pi} = 2\pi .$$
Or I could integrate over the circles 
$$\tag{4} H = p^2 + x^2 =  E$$ 
take advantage the Hamiltonian is symmetric on rotation in phase space
$$\tag{5}  Z = \int dp \, dx \, e^{-\beta (p^2 + x^2)} = 
\int  dE \, d\theta \, E \, e^{-\beta E} = 2\pi. $$
It seems I have forgotten that energy levels are quantized, so I should integrate over the circles 
$$\tag{6} H = E_n = \hbar \omega (n + \tfrac{1}{2}).$$

Where are the $E_n$ wavefunctions $\psi_n$ located in phase space? By Heisenberg uncertainty, we can't specify both $(p,x)$ in the phase plane.  Are they equidistributed on the circle $p^2 + x^2 = E$?
 A: (Not really an answer, but as one should not state such things in comments, I'm putting it here)
You commented: "This seems to boil down to the relationship between the phase space and the Hilbert space."
That's a deep question. I recommend reading Urs Schreiber's excellent post on how one gets from the phase space to the operators on a Hilbert space in a natural fashion. I'm not certain how the Wigner/Moyal picture of QM relates to quantum statistical mechanics, since we define the quantum canonical partition function to be $Z(\beta) := \mathrm{Tr}(\mathrm{e}^{\beta H})$ on the Hilbert space of states, as we basically draw the analogy that the classical phase space is the "space of states" for our classical theory, and the integral the trace over it, and generalize that to the quantum theory.
Also note that, in a quantum world, $\int\mathrm{d}x\mathrm{d}p\mathrm{e}^{-\beta H}$ is a bit of a non-sensical expression, since $H$ is an operator - the result of this would not be a number, which the partition function certainly should be.
A: Well, first of all, it is important to realize that the integrals (1) and (3) are not merely ordinary double integrals over a single $x$- and a single $p$-variable. Instead they are (Wick-rotated) path integrals containing, heuristically speaking, infinitely many integrations. 
The path integral derivation of the free particle and the harmonic oscillator can be found in many textbooks on quantum mechanics, see e.g. Refs. 1-3. For the free particle, see also e.g. this Phys.SE post.
Typically, one imposes Dirichlet Boundary Conditions (DBC)
$$\tag{D} x(t_i)=x_i\quad\text{and}\quad x(t_f)=x_f$$ 
on the position variable $x$ at initial and final times, $t_i$ and $t_f$, respectively. The next step is to "sum/integrate over all histories" consistent with eq. (D), cf. Refs. 1-3. 
As OP correctly observes, eq. (D) implies that the corresponding initial and final momentum variables $p(t_i)$ and $p(t_f)$ remain unknown according to the Heisenberg uncertainty principle.
References:


*

*R.P. Feynman and A.R. Hibbs, Quantum Mechanics and Path Integrals, 1965; Sections 3.

*J.J. Sakurai, Modern Quantum Mechanics, 1994, Section 2.5.

*J. Polchinski, String Theory, Vol. 1, 1998; Appendix A.1.
