The ideal gas as an urn model: derivation of the entropy formula