  The entropy of a de Sitter horizon was derived long ago by Gibbons and
Hawking via a gravitational partition function. Since there is no boundary at
which to define the temperature or energy of the ensemble, the statistical
foundation of their approach has remained obscure. To place the statistical
ensemble on a firm footing we introduce an artificial "York boundary", with
either canonical or microcanonical boundary conditions, as has been done
previously for black hole ensembles. The partition function and the density of
states are expressed as integrals over paths in the constrained, spherically
reduced phase space of pure 3+1 dimensional gravity with a positive
cosmological constant. Issues related to the domain and contour of integration
are analyzed, and the adopted choices for those are justified as far as
possible. The canonical ensemble includes a patch of spacetime without horizon,
as well as configurations containing a black hole or a cosmological horizon. We
study thermodynamic phases and (in)stability, and discuss an evolving reservoir
model that can stabilize the cosmological horizon in the canonical ensemble.
Finally, we explain how the Gibbons-Hawking partition function on the 4-sphere
can be derived as a limit of well-defined thermodynamic ensembles and, from
this viewpoint, why it computes the dimension of the Hilbert space of states
within a cosmological horizon.
