# Stochastic approximation

Stochastic approximation methods are a family of iterative methods typically used for root-finding problems or for optimization problems. The recursive update rules of stochastic approximation methods can be used, among other things, for solving linear systems when the collected data is corrupted by noise, or for approximating extreme values of functions which cannot be computed directly, but only estimated via noisy observations. In a nutshell, stochastic approximation algorithms deal with a function of the form $\displaystyle{ f(\theta) = \operatorname E_{\xi} [F(\theta,\xi)] }$ which is the expected value of a function depending on a random variable $\displaystyle{ \xi }$. The goal is to recover properties of such a function $\displaystyle{ f }$ without evaluating it directly. Instead, stochastic approximation algorithms use random samples of $\displaystyle{ F(\theta,\xi) }$ to efficiently approximate properties of $\displaystyle{ f }$ such as zeros or extrema.

Recently, stochastic approximations have found extensive applications in the fields of statistics and machine learning, especially in settings with big data. These applications range from stochastic optimization methods and algorithms, to online forms of the EM algorithm, reinforcement learning via temporal differences, and deep learning, and others. Stochastic approximation algorithms have also been used in the social sciences to describe collective dynamics: fictitious play in learning theory and consensus algorithms can be studied using their theory.

The earliest, and prototypical, algorithms of this kind are the Robbins–Monro and Kiefer–Wolfowitz algorithms introduced respectively in 1951 and 1952.

## Robbins–Monro algorithm

The Robbins–Monro algorithm, introduced in 1951 by Herbert Robbins and Sutton Monro, presented a methodology for solving a root finding problem, where the function is represented as an expected value. Assume that we have a function $\displaystyle{ M(\theta) }$, and a constant $\displaystyle{ \alpha }$, such that the equation $\displaystyle{ M(\theta) = \alpha }$ has a unique root at $\displaystyle{ \theta^* }$. It is assumed that while we cannot directly observe the function $\displaystyle{ M(\theta) }$, we can instead obtain measurements of the random variable $\displaystyle{ N(\theta) }$ where $\displaystyle{ \operatorname E[N(\theta)] = M(\theta) }$. The structure of the algorithm is to then generate iterates of the form:

$\displaystyle{ \theta_{n+1}=\theta_n - a_n(N(\theta_n) - \alpha) }$

Here, $\displaystyle{ a_1, a_2, \dots }$ is a sequence of positive step sizes. Robbins and Monro proved, Theorem 2 that $\displaystyle{ \theta_n }$ converges in $\displaystyle{ L^2 }$ (and hence also in probability) to $\displaystyle{ \theta^* }$, and Blum later proved the convergence is actually with probability one, provided that:

• $\displaystyle{ N(\theta) }$ is uniformly bounded,
• $\displaystyle{ M(\theta) }$ is nondecreasing,
• $\displaystyle{ M'(\theta^*) }$ exists and is positive, and
• The sequence $\displaystyle{ a_n }$ satisfies the following requirements:
$\displaystyle{ \qquad \sum^{\infty}_{n=0}a_n = \infty \quad \mbox{ and } \quad \sum^{\infty}_{n=0}a^2_n \lt \infty \quad }$

A particular sequence of steps which satisfy these conditions, and was suggested by Robbins–Monro, have the form: $\displaystyle{ a_n=a/n }$, for $\displaystyle{ a \gt 0 }$. Other series are possible but in order to average out the noise in $\displaystyle{ N(\theta) }$, the above condition must be met.

### Complexity results

1. If $\displaystyle{ f(\theta) }$ is twice continuously differentiable, and strongly convex, and the minimizer of $\displaystyle{ f(\theta) }$ belongs to the interior of $\displaystyle{ \Theta }$, then the Robbins–Monro algorithm will achieve the asymptotically optimal convergence rate, with respect to the objective function, being $\displaystyle{ \operatorname E[f(\theta_n) - f^*] = O(1/n) }$, where $\displaystyle{ f^* }$ is the minimal value of $\displaystyle{ f(\theta) }$ over $\displaystyle{ \theta \in \Theta }$.
2. Conversely, in the general convex case, where we lack both the assumption of smoothness and strong convexity, Nemirovski and Yudin have shown that the asymptotically optimal convergence rate, with respect to the objective function values, is $\displaystyle{ O(1/\sqrt{n}) }$. They have also proven that this rate cannot be improved.

### Subsequent developments and Polyak–Ruppert averaging

While the Robbins–Monro algorithm is theoretically able to achieve $\displaystyle{ O(1/n) }$ under the assumption of twice continuous differentiability and strong convexity, it can perform quite poorly upon implementation. This is primarily due to the fact that the algorithm is very sensitive to the choice of the step size sequence, and the supposed asymptotically optimal step size policy can be quite harmful in the beginning.

Chung(1954) and Fabian(1968) showed that we would achieve optimal convergence rate $\displaystyle{ O(1/\sqrt{n}) }$ with $\displaystyle{ a_n=\bigtriangledown^2f(\theta^*)^{-1}/n }$ (or $\displaystyle{ a_n=\frac{1}{(nM'(\theta^*))} }$). Lai and Robbins designed adaptive procedures to estimate $\displaystyle{ M'(\theta^*) }$ such that $\displaystyle{ \theta_n }$ has minimal asymptotic variance. However the application of such optimal methods requires much a priori information which is hard to obtain in most situations. To overcome this shortfall, Polyak(1991) and Ruppert(1988) independently developed a new optimal algorithm based on the idea of averaging the trajectories. Polyak and Juditsky also presented a method of accelerating Robbins–Monro for linear and non-linear root-searching problems through the use of longer steps, and averaging of the iterates. The algorithm would have the following structure:$\displaystyle{ \theta_{n+1} - \theta_n = a_n(\alpha - N(\theta_n)), \qquad \bar{\theta}_n = \frac{1}{n} \sum^{n-1}_{i=0} \theta_i }$The convergence of $\displaystyle{ \bar{\theta}_n }$ to the unique root $\displaystyle{ \theta^* }$ relies on the condition that the step sequence $\displaystyle{ \{a_n\} }$ decreases sufficiently slowly. That is

A1) $\displaystyle{ a_n \rightarrow 0, \qquad \frac{a_n - a_{n+1}}{a_n} = o(a_n) }$

Therefore, the sequence $\displaystyle{ a_n = n^{-\alpha} }$ with $\displaystyle{ 0 \lt \alpha \lt 1 }$ satisfies this restriction, but $\displaystyle{ \alpha = 1 }$ does not, hence the longer steps. Under the assumptions outlined in the Robbins–Monro algorithm, the resulting modification will result in the same asymptotically optimal convergence rate $\displaystyle{ O(1/\sqrt{n}) }$ yet with a more robust step size policy. Prior to this, the idea of using longer steps and averaging the iterates had already been proposed by Nemirovski and Yudin for the cases of solving the stochastic optimization problem with continuous convex objectives and for convex-concave saddle point problems. These algorithms were observed to attain the nonasymptotic rate $\displaystyle{ O(1/\sqrt{n}) }$.

A more general result is given in Chapter 11 of Kushner and Yin by defining interpolated time $\displaystyle{ t_n=\sum_{i=0}^{n-1}a_i }$, interpolated process $\displaystyle{ \theta^n(\cdot) }$ and interpolated normalized process $\displaystyle{ U^n(\cdot) }$ as

$\displaystyle{ \theta^n(t)=\theta_{n+i},\quad U^n(t)=(\theta_{n+i}-\theta^*)/\sqrt{a_{n+i}}\quad\mbox{for}\quad t\in[t_{n+i}-t_n,t_{n+i+1}-t_n),i\ge0 }$Let the iterate average be $\displaystyle{ \Theta_n=\frac{a_n}{t}\sum_{i=n}^{n+t/a_n-1}\theta_i }$ and the associate normalized error to be $\displaystyle{ \hat{U}^n(t)=\frac{\sqrt{a_n}}{t}\sum_{i=n}^{n+t/a_n-1}(\theta_i-\theta^*) }$.

With assumption A1) and the following A2)

A2) There is a Hurwitz matrix $\displaystyle{ A }$ and a symmetric and positive-definite matrix $\displaystyle{ \Sigma }$ such that $\displaystyle{ \{U^n(\cdot)\} }$ converges weakly to $\displaystyle{ U(\cdot) }$, where $\displaystyle{ U(\cdot) }$ is the statisolution to$\displaystyle{ dU = AU \, dt +\Sigma^{1/2} \, dw }$where $\displaystyle{ w(\cdot) }$ is a standard Wiener process.

satisfied, and define $\displaystyle{ \bar{V}=(A^{-1})'\Sigma(A')^{-1} }$. Then for each $\displaystyle{ t }$,

$\displaystyle{ \hat{U}^n(t)\stackrel{\mathcal{D}}{\longrightarrow}\mathcal{N}(0,V_t),\quad \text{where}\quad V_t=\bar{V}/t+O(1/t^2). }$

The success of the averaging idea is because of the time scale separation of the original sequence $\displaystyle{ \{\theta_n\} }$ and the averaged sequence $\displaystyle{ \{\Theta_n\} }$, with the time scale of the former one being faster.

### Application in stochastic optimization

Suppose we want to solve the following stochastic optimization problem

$\displaystyle{ g(\theta^*) = \min_{\theta\in\Theta}\operatorname{E}[Q(\theta,X)], }$where $\displaystyle{ g(\theta) = \operatorname{E}[Q(\theta,X)] }$ is differentiable and convex, then this problem is equivalent to find the root $\displaystyle{ \theta^* }$ of $\displaystyle{ \nabla g(\theta) = 0 }$. Here $\displaystyle{ Q(\theta,X) }$ can be interpreted as some "observed" cost as a function of the chosen $\displaystyle{ \theta }$ and random effects $\displaystyle{ X }$. In practice, it might be hard to get an analytical form of $\displaystyle{ \nabla g(\theta) }$, Robbins–Monro method manages to generate a sequence $\displaystyle{ (\theta_n)_{n\geq 0} }$ to approximate $\displaystyle{ \theta^* }$ if one can generate $\displaystyle{ (X_n)_{n\geq 0} }$ , in which the conditional expectation of $\displaystyle{ X_n }$ given $\displaystyle{ \theta_n }$ is exactly $\displaystyle{ \nabla g(\theta_n) }$, i.e. $\displaystyle{ X_n }$ is simulated from a conditional distribution defined by

$\displaystyle{ \operatorname{E}[H(\theta,X)|\theta = \theta_n] = \nabla g(\theta_n). }$

Here $\displaystyle{ H(\theta, X) }$ is an unbiased estimator of $\displaystyle{ \nabla g(\theta) }$. If $\displaystyle{ X }$ depends on $\displaystyle{ \theta }$, there is in general no natural way of generating a random outcome $\displaystyle{ H(\theta, X) }$ that is an unbiased estimator of the gradient. In some special cases when either IPA or likelihood ratio methods are applicable, then one is able to obtain an unbiased gradient estimator $\displaystyle{ H(\theta, X) }$. If $\displaystyle{ X }$ is viewed as some "fundamental" underlying random process that is generated independently of $\displaystyle{ \theta }$, and under some regularization conditions for derivative-integral interchange operations so that $\displaystyle{ \operatorname{E}\Big[\frac{\partial}{\partial\theta}Q(\theta,X)\Big] = \nabla g(\theta) }$, then $\displaystyle{ H(\theta, X) = \frac{\partial}{\partial \theta}Q(\theta, X) }$ gives the fundamental gradient unbiased estimate. However, for some applications we have to use finite-difference methods in which $\displaystyle{ H(\theta, X) }$ has a conditional expectation close to $\displaystyle{ \nabla g(\theta) }$ but not exactly equal to it.

We then define a recursion analogously to Newton's Method in the deterministic algorithm:

$\displaystyle{ \theta_{n+1} = \theta_n - \varepsilon_n H(\theta_n,X_{n+1}). }$

#### Convergence of the algorithm

The following result gives sufficient conditions on $\displaystyle{ \theta_n }$ for the algorithm to converge:

C1) $\displaystyle{ \varepsilon_n \geq 0, \forall\; n\geq 0. }$

C2) $\displaystyle{ \sum_{n=0}^\infty \varepsilon_n = \infty }$

C3) $\displaystyle{ \sum_{n=0}^{\infty}\varepsilon_n^2 \lt \infty }$

C4) $\displaystyle{ |X_n| \leq B, \text{ for a fixed bound } B. }$

C5) $\displaystyle{ g(\theta) \text{ is strictly convex, i.e.} }$

$\displaystyle{ \inf_{\delta\leq |\theta - \theta^*|\leq 1/\delta}\langle\theta-\theta^*, \nabla g(\theta)\rangle \gt 0,\text{ for every } 0\lt \delta \lt 1. }$

Then $\displaystyle{ \theta_n }$ converges to $\displaystyle{ \theta^* }$ almost surely.

Here are some intuitive explanations about these conditions. Suppose $\displaystyle{ H(\theta_n, X_{n+1}) }$ is a uniformly bounded random variables. If C2) is not satisfied, i.e. $\displaystyle{ \sum_{n=0}^\infty \varepsilon_n \lt \infty }$ , then$\displaystyle{ \theta_n - \theta_0 = -\sum_{i=0}^{n-1} \varepsilon_i H(\theta_i, X_{i+1}) }$is a bounded sequence, so the iteration cannot converge to $\displaystyle{ \theta^* }$ if the initial guess $\displaystyle{ \theta_0 }$ is too far away from $\displaystyle{ \theta^* }$. As for C3) note that if $\displaystyle{ \theta_n }$ converges to $\displaystyle{ \theta^* }$ then

$\displaystyle{ \theta_{n+1} - \theta_n = -\varepsilon_n H(\theta_n, X_{n+1}) \rightarrow 0, \text{ as } n\rightarrow \infty. }$ so we must have $\displaystyle{ \varepsilon_n \downarrow 0 }$ ，and the condition C3) ensures it. A natural choice would be $\displaystyle{ \varepsilon_n = 1/n }$. Condition C5) is a fairly stringent condition on the shape of $\displaystyle{ g(\theta) }$; it gives the search direction of the algorithm.

#### Example (where the stochastic gradient method is appropriate)

Suppose $\displaystyle{ Q(\theta, X) = f(\theta) + \theta^T X }$, where $\displaystyle{ f }$ is differentiable and $\displaystyle{ X\in \mathbb{R}^p }$ is a random variable independent of $\displaystyle{ \theta }$. Then $\displaystyle{ g(\theta)=\operatorname{E}[Q(\theta,X)] = f(\theta)+\theta^T\operatorname{E}X }$ depends on the mean of $\displaystyle{ X }$, and the stochastic gradient method would be appropriate in this problem. We can choose $\displaystyle{ H(\theta, X) = \frac{\partial}{\partial\theta}Q(\theta,X) = \frac{\partial}{\partial\theta}f(\theta) + X. }$

## Kiefer–Wolfowitz algorithm

The Kiefer–Wolfowitz algorithm was introduced in 1952 by Jacob Wolfowitz and Jack Kiefer, and was motivated by the publication of the Robbins–Monro algorithm. However, the algorithm was presented as a method which would stochastically estimate the maximum of a function. Let $\displaystyle{ M(x) }$ be a function which has a maximum at the point $\displaystyle{ \theta }$. It is assumed that $\displaystyle{ M(x) }$ is unknown; however, certain observations $\displaystyle{ N(x) }$, where $\displaystyle{ \operatorname E[N(x)] = M(x) }$, can be made at any point $\displaystyle{ x }$. The structure of the algorithm follows a gradient-like method, with the iterates being generated as follows:

$\displaystyle{ x_{n+1} = x_n + a_n \bigg(\frac{N(x_n + c_n) - N(x_n -c_n)}{2 c_n} \bigg) }$

where $\displaystyle{ N(x_n+c_n) }$ and $\displaystyle{ N(x_n-c_n) }$ are independent, and the gradient of $\displaystyle{ M(x) }$ is approximated using finite differences. The sequence $\displaystyle{ \{c_n\} }$ specifies the sequence of finite difference widths used for the gradient approximation, while the sequence $\displaystyle{ \{a_n\} }$ specifies a sequence of positive step sizes taken along that direction. Kiefer and Wolfowitz proved that, if $\displaystyle{ M(x) }$ satisfied certain regularity conditions, then $\displaystyle{ x_n }$ will converge to $\displaystyle{ \theta }$ in probability as $\displaystyle{ n\to\infty }$, and later Blum in 1954 showed $\displaystyle{ x_n }$ converges to $\displaystyle{ \theta }$ almost surely, provided that:

• $\displaystyle{ \operatorname{Var}(N(x))\le S\lt \infty }$ for all $\displaystyle{ x }$.
• The function $\displaystyle{ M(x) }$ has a unique point of maximum (minimum) and is strong concave (convex)
• The algorithm was first presented with the requirement that the function $\displaystyle{ M(\cdot) }$ maintains strong global convexity (concavity) over the entire feasible space. Given this condition is too restrictive to impose over the entire domain, Kiefer and Wolfowitz proposed that it is sufficient to impose the condition over a compact set $\displaystyle{ C_0 \subset \mathbb R^d }$ which is known to include the optimal solution.
• The function $\displaystyle{ M(x) }$ satisfies the regularity conditions as follows:
• There exists $\displaystyle{ \beta\gt 0 }$ and $\displaystyle{ B\gt 0 }$ such that $\displaystyle{ |x'-\theta|+|x''-\theta|\lt \beta \quad \Longrightarrow \quad |M(x')-M(x'')|\lt B|x'-x''| }$
• There exists $\displaystyle{ \rho\gt 0 }$ and $\displaystyle{ R\gt 0 }$ such that $\displaystyle{ |x'-x''|\lt \rho \quad \Longrightarrow \quad |M(x')-M(x'')|\lt R }$
• For every $\displaystyle{ \delta\gt 0 }$, there exists some $\displaystyle{ \pi(\delta)\gt 0 }$ such that $\displaystyle{ |z-\theta|\gt \delta \quad \Longrightarrow \quad \inf_{\delta/2\gt \varepsilon\gt 0}\frac{|M(z+\varepsilon)-M(z-\varepsilon)|}{\varepsilon}\gt \pi(\delta) }$
• The selected sequences $\displaystyle{ \{a_n\} }$ and $\displaystyle{ \{c_n\} }$ must be infinite sequences of positive numbers such that
• $\displaystyle{ \quad c_n \rightarrow 0\quad \text{as}\quad n\to\infty }$
• $\displaystyle{ \sum^\infty_{n=0} a_n =\infty }$
• $\displaystyle{ \sum^\infty_{n=0} a_nc_n \lt \infty }$
• $\displaystyle{ \sum^\infty_{n=0} a_n^2c_n^{-2} \lt \infty }$

A suitable choice of sequences, as recommended by Kiefer and Wolfowitz, would be $\displaystyle{ a_n = 1/n }$ and $\displaystyle{ c_n = n^{-1/3} }$.

### Subsequent developments and important issues

1. The Kiefer Wolfowitz algorithm requires that for each gradient computation, at least $\displaystyle{ d+1 }$ different parameter values must be simulated for every iteration of the algorithm, where $\displaystyle{ d }$ is the dimension of the search space. This means that when $\displaystyle{ d }$ is large, the Kiefer–Wolfowitz algorithm will require substantial computational effort per iteration, leading to slow convergence.
1. To address this problem, Spall proposed the use of simultaneous perturbations to estimate the gradient. This method would require only two simulations per iteration, regardless of the dimension $\displaystyle{ d }$.
2. In the conditions required for convergence, the ability to specify a predetermined compact set that fulfills strong convexity (or concavity) and contains the unique solution can be difficult to find. With respect to real world applications, if the domain is quite large, these assumptions can be fairly restrictive and highly unrealistic.

## Further developments

An extensive theoretical literature has grown up around these algorithms, concerning conditions for convergence, rates of convergence, multivariate and other generalizations, proper choice of step size, possible noise models, and so on. These methods are also applied in control theory, in which case the unknown function which we wish to optimize or find the zero of may vary in time. In this case, the step size $\displaystyle{ a_n }$ should not converge to zero but should be chosen so as to track the function., 2nd ed., chapter 3

C. Johan Masreliez and R. Douglas Martin were the first to apply stochastic approximation to robust estimation.

The main tool for analyzing stochastic approximations algorithms (including the Robbins–Monro and the Kiefer–Wolfowitz algorithms) is a theorem by Aryeh Dvoretzky published in the proceedings of the third Berkeley symposium on mathematical statistics and probability, 1956.