The Onsager–Machlup function is a function that summarizes the dynamics of a continuous stochastic process. It is used to define a probability density for a stochastic process, and it is similar to the Lagrangian of a dynamical system. It is named after Lars Onsager and Stefan Machlup who were the first to consider such probability densities.
The dynamics of a continuous stochastic process X from time t = 0 to t = T in one dimension, satisfying a stochastic differential equation
 
where W is a Wiener process, can in approximation be described by the probability density function of its value xi at a finite number of points in time ti:
 
where
 
and Δti = ti+1 − ti > 0, t1 = 0 and tn = T. A similar approximation is possible for processes in higher dimensions. The approximation is more accurate for smaller time step sizes Δti, but in the limit Δti → 0 the probability density function becomes ill defined, one reason being that the product of terms
 
diverges to infinity. In order to nevertheless define a density for the continuous stochastic process X, ratios of probabilities of X lying within a small distance ε from smooth curves φ1 and φ2 are considered:
![{\displaystyle {\frac {P\left(\left|X_{t}-\varphi _{1}(t)\right|\leq \varepsilon {\text{ for every }}t\in [0,T]\right)}{P\left(\left|X_{t}-\varphi _{2}(t)\right|\leq \varepsilon {\text{ for every }}t\in [0,T]\right)}}\to \exp \left(-\int _{0}^{T}L\left(\varphi _{1}(t),{\dot {\varphi }}_{1}(t)\right)\,dt+\int _{0}^{T}L\left(\varphi _{2}(t),{\dot {\varphi }}_{2}(t)\right)\,dt\right)}](./ac20fddc7b4b35007fd6f1fdad2fa15c7f5a16a7.svg) 
as ε → 0, where L is the Onsager–Machlup function.