4. Canonical ensemble