  Statistical thermodynamics delivers the probability distribution of the
equilibrium state of matter through the constrained maximization of a special
functional, entropy. Its elegance and enormous success have led to numerous
attempts to decipher its language and make it available to problems outside
physics, but a formal generalization has remained elusive. Here we show how the
formalism of thermodynamics can be applied to any stochastic process. We view a
stochastic process as a random walk on the event space of a random variable
that produces a feasible distribution of states. The set of feasible
distributions obeys thermodynamics: the most probable distribution is the
canonical distribution, it maximizes the functionals of statistical mechanics,
and its parameters satisfy the same Legendre relationships. Thus the formalism
of thermodynamics -- no new functionals beyond those already encountered in
statistical physics -- is shown to be a stochastic calculus, a universal
language of probability distributions and stochastic processes.
