# Mean sojourn time

The mean sojourn time (or sometimes mean waiting time) for an object in a dynamical system is the amount of time an object is expected to spend in a system before leaving the system permanently. This concept is widely used in various fields, including physics, chemistry, and stochastic processes, to study the behavior of systems over time.

## Concepts
### Concept

Imagine someone is standing in line to buy a ticket at the counter. After a minute, by observing the number of customers behind them, this person can estimate the rate at which customers are entering the system (in this case, the waiting line) per unit time (one minute). By dividing the number of customers ahead by this "flow" of customers, one can estimate how much longer the wait will be to reach the counter.
Formally, consider the waiting line as a system S into which there is a flow of particles (customers) and where the process of “buying a ticket” means that the particle leaves the system. This waiting time is commonly referred to as transit time. Applying Little's theorem once, the expected steady state number of particles in S equals the flow of particles into S times the mean transit time. Similar theorems have been discovered in other fields, and in physiology it was earlier known as one of the Stewart-Hamilton equations (which is used to estimate the blood volume of organs).

### Generalizations

Consider a system S in the form of a closed domain of finite volume in the Euclidean space. Further, consider the situation where there is a stream of ”equivalent” particles into S (number of particles per time unit) where each particle retains its identity while being in S and eventually – after a finite time – leaves the system irreversibly (i.e., for these particles the system is "open").
The figure above depicts the thought motion history of a single such particle, which thus moves in and out of subsystem s three times, each of which results in a transit time, namely the time spent in the subsystem between entrance and exit. The sum of these transit times is the sojourn time of s for that particular particle. If the motions of the particles are looked upon as realizations of one and the same stochastic process, it is meaningful to speak of the mean value of this sojourn time. That is, the mean sojourn time of a subsystem is the total time a particle is expected to spend in the subsystem s before leaving S for good.
To see a practical significance of this quantity, we must understand that as a law of physics if the stream of particles into S is constant and all other relevant factors are kept constant, S will eventually reach steady state (i.e., the number and distribution of particles is constant everywhere in S). It can then be demonstrated that the steady state number of particles in the subsystem s equals the stream of particles into the system S times the mean sojourn time of the subsystem. This is thus a more general form of what above was referred to as Little's theorem, and it might be called the mass-time equivalence:
    (expected steady state amount in s) = (stream into S) (mean sojourn time of s)
This has also been called the occupancy principle (where mean sojourn time is then referred to as occupancy). This mass-time equivalence has been applied in medicine for the study of metabolism of individual organs.
This is a generalization of what in queuing theory is sometimes referred to as Little's theorem that applies only to the whole system S (not to an arbitrary subsystem as in the mass-time equivalence); the mean sojourn time in the Little's theorem can be interpreted as mean transit time.
As likely evident from the discussion of the figure above, there is a fundamental difference between the meaning of the two quantities of sojourn time and transit time: the generality of the mass-time equivalence is very much due to the special meaning of the notion of sojourn time. When the whole system is considered (as in Little's law) is it true that sojourn time always equals transit time.
Examples of Applications:
1) Queuing Theory: In queuing systems, it corresponds to the average time a customer or job spends in the system or a specific queue.
2) Physics: Used to describe trapping times in potential wells or energy barriers in molecular dynamics.
3) Markov Chains: Describes the time a system spends in a transient state before transitioning.