  The selection of an equilibrium state by maximising the entropy of a system,
subject to certain constraints, is often powerfully motivated as an exercise in
logical inference, a procedure where conclusions are reached on the basis of
incomplete information. But such a framework can be more compelling if it is
underpinned by dynamical arguments, and we show how this can be provided by
stochastic thermodynamics, where an explicit link is made between the
production of entropy and the stochastic dynamics of a system coupled to an
environment. The separation of entropy production into three components allows
us to select a stationary state by maximising the change, averaged over all
realisations of the motion, in the principal relaxational or nonadiabatic
component, equivalent to requiring that this contribution to the entropy
production should become time independent for all realisations. We show that
this recovers the usual equilibrium probability density function (pdf) for a
conservative system in an isothermal environment, as well as the stationary
nonequilibrium pdf for a particle confined to a potential under nonisothermal
conditions, and a particle subject to a constant nonconservative force under
isothermal conditions. The two remaining components of entropy production
account for a recently discussed thermodynamic anomaly between over- and
underdamped treatments of the dynamics in the nonisothermal stationary state.
