1 Introduction

Opinion dynamics models have attracted a lot of attention, and there are many analytical and numerical studies that consider different models arising from many different fields. In much of the literature, an opinion dynamics model is a system with a large number of opinion variables, x i (t), i=1,…,N, taking values in \(\mathbb {R}^{n}\). The time evolution of the opinion variables is governed by an attractive interaction between any two opinion variables, often taken to be a nonnegative function of the Euclidean distance of the two opinion variables and may also be time dependent. The most interesting feature of such a model is that opinions only interact locally and the influence function is compactly supported, interpreted as bounded confidence. In this case, it is of interest to know whether the system will exhibit consensus convergence, which means that all the opinion variables converge to the same point as time tends to infinity. Except for some specific consensus models, a broad sufficient condition to have consensus convergence for a general class of models is not known. However, several studies have shown that for a variety of different types of consensus building interactions, and without external forces or randomness, the opinions will converge to possibly several clusters. In this case, the distance between distinct clusters should be larger than the support of the influence region. But it is not known, in general, how to determine the number of clusters.

A more realistic way to model opinion dynamics is to add external randomness to the system. In this case, the model becomes a system of N stochastic processes and usually the randomness in the model is independent from one opinion holder or agent to another. Many deterministic techniques can also be used in the stochastic case, but some methods, such as the use of master equations, are particularly useful in stochastic models. When the external noise is large in the stochastic models then the tendency to cluster is effectively eliminated as the system is dominated by the noise. This is a phenomenon seen elsewhere in statistical physics as well. The strength of the noise or randomness must be below a critical value in order for cluster formation to emerge and evolve.

The literature in opinion dynamics is very extensive so we mention only a few papers that have guided our own work. Hegselmann and Krause [13] consider a discrete-time evolution model, in which the opinions in the next step are the average of the current opinions within a specified range of the influence region. Pineda et al. [25] add noise to the Hegselmann–Krause model and determine the critical strength of the noise so as to have cluster formation, using a master equation approach and linear stability analysis. The same method is also used in [23, 24] on the Deffuant–Weisbuch model [9]. In [4], the authors take the limit as the number of opinions goes to infinity and consider the distribution of the opinions (the Eulerian approach), instead of tracking every single opinion in the Hegselmann–Krause model (the Lagrangian approach), and [21] further discuss the case with external forces. The long time behavior and a sufficient condition for consensus convergence of the Hegselmann–Krause model are considered in [2, 3, 26]. The long time behavior of the Hegselmann–Krause model with a general influence function is discussed in [16, 22]. The Hegselmann–Krause model involving different types of agents is considered in [14]. Some recent development of the study of opinion dynamics are in [19, 22]. Other, related relevant works are [1, 57, 10, 12, 15, 18, 20].

Our contributions in this paper are the following. We consider a stochastic opinion model where every opinion is influenced by an independent Brownian motion. By the mean field limit theory, the empirical probability measure of the opinions converges, as the size of the population goes to infinity, to a solution of a nonlinear Fokker–Planck equation. Using a linear stability analysis, we estimate the number of clusters, the time to cluster formation, and the critical strength of the Brownian motions to have cluster formation. The linear stability analysis can be applied to both deterministic and stochastic models. We also discuss the behavior of the system after the initial cluster formation but before further cluster consolidation, where the centers of the clusters are expected to behave like independent Brownian motions. Finally, we consider the long time behavior of the system. Once clusters are formed, their centers behave like Brownian motions until further merging. After consensus convergence, where there is only one cluster, there is a small probability that all the opinions inside the limit cluster will spread out and the system will become an independent agent evolution. Extensive numerical simulations are carried out to support our analysis and remarks about cluster formation and evolution.

The paper is organized as follows. The interacting agent model is presented in Section 2. The mean field limit is presented briefly in Section 3. The linearized stability analysis of the governing nonlinear Fokker–Planck equation is presented in Section 4 when there is no external noise. The results of numerical simulations are also presented in this section. In Section 5, we extend the analysis of the previous section to the stochastic case when there are external noise influences. We also present the results of numerical simulations in the stochastic case. In Section 6, we comment briefly about the long time behavior in the stochastic case when there is clustering. We end with a brief summary and conclusions in Section 7.

2 The Interacting Agent Model

The opinion model we consider in this paper is (see [22, Eq. (1.2a)])

$$ dx_{i} = -\frac{1}{N} \sum\limits_{j=1}^{N} a_{ij} (x_{i}-x_{j}) dt+ \sigma dW^{i}(t), $$
(1)

where x i (t) is the agent i’s opinion modeled as real valued process, where t is time and i=1,…,N. The coefficients a i j denote the strength of the interaction between x i and x j and they are a function of the distance between x i and x j

$$ a_{ij} = \phi(|x_{i}-x_{j} |). $$

The interesting case is when the influence function ϕ is non-negative and compactly supported. In other words, the interactions are attractive and the agent i affects only the other agents that have similar opinions. Here, we assume that ϕ is compactly supported in [0,R 0]

$$ \phi(r) =\phi_{0}\left( \frac{r}{R_{0}} \right), $$
(2)

where supp(ϕ 0)=[0,1].

The W i(t), i=1,…,N are independent standard Brownian motions that model the uncertainties of the agents’ opinions, and σ is a non-negative constant quantifying the strength of the uncertainties. If σ=0, then there is no randomness in this model and (1) is a deterministic system, while if σ>0, the system becomes stochastic.

For the purposes of the analysis below, we consider the model (1) on the torus [0,L] instead of the real line \(\mathbb R\), i.e., we consider the model in the bounded space [0,L] with periodic boundary conditions. The assumption of periodic boundary conditions is mostly for simplifying the analysis. Although this assumption may not be appropriate in some applications, we found that the results obtained using it are numerically consistent with the same model in full space or in a finite interval with reflecting boundary conditions. The later two are in general more realistic for many applications. We note that the same periodicity assumption for the analysis of the opinion dynamics is also used in [2325].

3 The Mean Field Limit

At time t, we consider the empirical probability measure ρ N(t,d x) of the opinions of all the agents

$$\rho^{N}(t,dx) = \frac{1}{N} \sum\limits_{j=1}^{N} \delta_{x_{j}(t)}(dx). $$

Here, δ x (d x) is the Dirac measure with the point mass at x. The empirical probability measure ρ N(t,d x) is a measure valued stochastic process. We assume that as \(N\to \infty \), ρ N(0,d x) converges weakly, in probability to ρ 0(d x) which is a deterministic measure with density ρ 0(x). By using the well-known mean field asymptotic theory (see, for example, [8, 11, 17]), it can be shown that as \(N\to \infty \), ρ N(t,d x) converges weakly, in probability to ρ(t,d x), for \(0\leq t\leq T<\infty \), a deterministic probability measure. Under suitable conditions, the limit measure has a density ρ(t,x) which satisfies (in a weak sense) the nonlinear Fokker–Plank equation

$$ \frac{\partial \rho}{\partial t} (t,x) = \frac{\partial}{\partial x} \left\{\left[ \int \rho(t,x-y) y \phi(|y|) dy \right]\rho(t,x) \right\} + \frac{\sigma^{2}}{2} \frac{\partial^{2} \rho}{\partial x^{2}}(t,x), $$
(3)

with given initial density ρ 0(x). In particular, if x 1(0),…,x N (0) are sampled independently and identically according to the uniform measure over [0,L], then the result holds true and the initial measure has constant density ρ 0(x)=1/L.

In this paper, we assume that N is large and view the mean field limit as the defining problem. Therefore, we will analyze the overall behavior of the opinion dynamics, x 1(t),…,x N (t), by analyzing instead the nonlinear Fokker–Planck (3).

4 Deterministic Consensus Convergence: σ=0

We will follow a modulational instability approach to study the mean field limit when (σ=0), also analyzed in [16, 22]. We look for conditions so as to have consensus convergence where all the opinions converge to a cluster as \(t\to \infty \). We also analyze the number of clusters if there is no consensus convergence and the time to cluster formation, that is, the onset of cluster formation.

4.1 Linear Stability Analysis

We first linearize the Fokker–Planck equation (3) with σ=0 by assuming that ρ(t,x) = ρ 0 + ρ 1(t,x)=1/L + ρ 1(t,x). Substituting ρ(t,x) = ρ 0 + ρ 1(t,x) into (3) and assuming that ρ 1 is a small perturbation of ρ so that the \(O({\rho _{1}^{2}})\) term is negligible, we find that ρ 1(t,x) satisfies

$$\begin{array}{@{}rcl@{}} \frac{\partial \rho_{1}}{\partial t}(t,x) &=& \frac{\partial}{\partial x}\left[\int \rho_{0}y\phi(|y|)dy \rho_{1}(t,x)\right] + \frac{\partial}{\partial x}\left[\int \rho_{1}(t,x-y)y\phi(|y|)dy \rho_{0}\right]\\ &=& \rho_{0} \int \frac{\partial \rho_{1}}{\partial x}(t,x-y) y \phi(|y|) dy. \end{array} $$
(4)

The last equality in (4) holds because ϕ(|y|) is an even function and therefore\(\int y\phi (|y|)dy=0\).

By taking the Fourier transform in x, \(\hat {\rho }_{1}(t,k)={{\int }_{0}^{L}} \rho _{1}(t,x) e^{-ikx} dx\), with the discrete set of frequencies k in

$$\mathcal{K} = \{2\pi n /L, n \in \mathbb Z\}, $$

we find from (4) that

$$ \frac{\partial \hat{\rho}_{1}}{\partial t} (t,k) = \left[ i \rho_{0} k \int e^{-iky} y \phi(|y|) dy \right]\hat{\rho}_{1}(t,k), $$
(5)

which gives the growth rates of the modes

$$ \gamma_{k} = \text{Re} \left[ i \rho_{0} k \int e^{-iky} y \phi(|y|) dy \right] = \rho_{0} k \int \sin(ky) y \phi(|y|) dy. $$
(6)

We can see that for each k, \(|\hat {\rho }_{1}(t,k)| = |\hat {\rho }_{1}(0,k)|\exp (\gamma _{k} t)\). By replacing ϕ with ϕ 0 (see (2)), we can rewrite γ k as

$$ \gamma_{k} = \rho_{0} R_{0} \psi(kR_{0} ),\quad \psi(q) = 2q {{\int}_{0}^{1}} \phi_{0}(s) s \sin(q s) ds. $$
(7)

The growth rate γ k is maximal for \(k = \pm k_{\max }\) with \(k_{\max } := q_{\max }/R_{0}\), more exactly, for k equal to plus or minus the discrete frequency \(k_{\max }\) in the set \(\mathcal K\) that maximizes ψ(k R 0), which is close to \(q_{\max }/R_{0}\). Here

$$ q_{\max} = \underset{q>0}{\arg\max} [\psi(q)] = \underset{q>0}{\arg\max} \left[2q {{\int}_{0}^{1}} \phi_{0}(s) s \sin(q s) ds\right]. $$
(8)

The optimal (continuous) frequency \(q_{\max }\) is positive and finite under general conditions since \(\psi (q) \simeq 2 q^{2} {{\int }_{0}^{1}} s^{2} \phi _{0}(s) ds\) for 0≤q≪1 and ψ(q) is bounded or decays to zero at infinity depending on the regularity of ϕ 0.

4.2 Fluctuation Theory

By the central limit theorem, if we assume that the initial opinions x 1(0),…,x N (0) are sampled identically according to the uniform distribution over the domain [0,L], then

$${\rho^{N}_{1}}(t=0,dx) := \sqrt{N} \left( \rho^{N}(t=0,dx) - \rho_{0}(dx) \right) = \sqrt{N} \left( \frac{1}{N} \sum\limits_{i=1}^{N}\delta_{x_{i}(0)}(dx) - \frac{dx}{L} \right) $$

converges in distribution as \(N \to \infty \) to the measure ρ 1(t=0,d x), whose frequency components, for \(k \in \mathcal K\backslash \{0\}\),

$$\begin{array}{@{}rcl@{}} \hat{\rho}_{1}(t=0,k) &=& \underset{N\to\infty}{\lim}{{\int}_{0}^{L}} \sqrt{N}e^{-ikx}\left( \frac{1}{N}\sum\limits_{j=1}^{N}\delta_{x_{j}(0)}(dx)-\frac{dx}{L}\right)\\ &=& \underset{N\to\infty}{\lim} \sqrt{N} \left( \frac{1}{N}\sum\limits_{j=1}^{N} e^{-ikx_{j}(0)} - {{\int}_{0}^{L}} \frac{1}{L}e^{-ikx}dx \right)\\ &=& \underset{N\to\infty}{\lim} \sqrt{N} \left( \frac{1}{N}\sum\limits_{j=1}^{N} e^{-ikx_{j}(0)}\right) \end{array} $$

are independent and identically distributed with complex circular Gaussian random variables with mean zero and variance 1

$$\mathbb E \left[ \hat{\rho}_{1}(t=0,k) \right]=0,\quad \mathbb E \left[ \hat{\rho}_{1}(t=0,k) \overline{\hat{\rho}_{1}(t=0,k^{\prime})} \right] = \delta_{kk^{\prime}},\quad k,k^{\prime} \in {\mathcal K} \backslash \{0\}, $$

\(\hat {\rho }_{1}(t=0,-k) = \overline { \hat {\rho }_{1}(t=0,k) }\), while \(\hat {\rho }_{1}(t=0,k=0) =0\).

For any T, the measure-valued process

$${\rho^{N}_{1}}(t,dx) := \sqrt{N} \left( \rho^{N}(t,dx) - \rho_{0}(dx) \right), \quad t \in [0,T] $$

converges in distribution as \(N \to \infty \) to a measure-valued process ρ 1(t,d x) whose density ρ 1(t,x) satisfies the deterministic PDE

$$ \frac{\partial \rho_{1}}{\partial t} (t,x) = \rho_{0} \int \frac{\partial \rho_{1}}{\partial x}(t,x-y) y \phi(|y|) dy $$
(9)

with the random initial condition described above.

Consequently, combining with (5) and (6), at any time t, the frequency components \(\hat {\rho }_{1}(t,k)\), \(k \in \mathcal K \backslash \{0\}\), are independent complex circular Gaussian random variables, with mean zero and variance \(\exp (2 \gamma _{k} t)\)

$$\mathbb E \left[ \hat{\rho}_{1}(t,k) \overline{\hat{\rho}_{1}(t,k^{\prime})} \right] = \delta_{kk^{\prime}} \exp (2 \gamma_{k} t), \quad k,k^{\prime} \in \mathcal K \backslash \{0\}, $$

\(\hat {\rho }_{1}(t,-k) = \overline {\hat {\rho }_{1}(t,k)}\), while \(\hat {\rho }_{1}(t,k=0)=0\). Therefore,

$$\begin{array}{@{}rcl@{}} \mathbb E[\rho_{1}(t,x)\rho_{1}(t,x^{\prime})] &=& \mathbb E\left[\sum\limits_{k}\hat{\rho}_{1}(t,k)\frac{e^{ikx}}{L} \sum\limits_{k}\hat{\rho}_{1}(t,k)\frac{e^{ikx^{\prime}}}{L}\right]\\ & =& \sum\limits_{k} \mathbb E\left[\hat{\rho}_{1}(t,k)\frac{e^{ikx}}{L} \hat{\rho}_{1}(t,-k)\frac{e^{-ikx^{\prime}}}{L}\right] = \frac{1}{L^{2}} \sum\limits_{k\neq 0} e^{2\gamma_{k} t} e^{ik(x-x^{\prime})}. \end{array} $$

For large times, the spectrum of ρ 1(t,x) becomes concentrated around the optimal wavenumber \(k_{\max }\). We can expand \(\gamma _{k} = \gamma _{\max } + \frac {1}{2} \gamma ^{\prime \prime }_{\max } (k-k_{\max })^{2}\) for k around \(k_{\max }\) and use a continuum approximation for the discrete sum

$$\begin{array}{@{}rcl@{}} &&\mathbb E[\rho_{1}(t,x)\rho_{1}(t,x^{\prime})] = \frac{1}{L^{2}} \sum\limits_{k\neq 0} e^{2\gamma_{k} t} e^{ik(x-x^{\prime})} \simeq \frac{1}{L^{2}} {\int}_{-\infty}^{\infty} e^{2\gamma_{k} t} e^{ik(x-x^{\prime})}\frac{L}{2\pi} dk\\ &&\quad =\frac{1}{2\pi L} {\int}_{-\infty}^{\infty} e^{2\gamma_{k} t} e^{ik(x-x^{\prime})} dk \simeq \frac{1}{\pi L}\text{Re}\left( {\int}_{0}^{\infty} e^{2(\gamma_{\max}+\frac{1}{2}\gamma^{\prime\prime}_{\max}(k-k_{\max})^{2})t} e^{ik(x-x^{\prime})}dk\right)\\ &&\quad =\frac{1}{\pi L}\text{Re}\left( e^{2\gamma_{\max}t}{\int}_{0}^{\infty} e^{\gamma^{\prime\prime}_{\max}(k-k_{\max})^{2}t}e^{ik(x-x^{\prime})}dk\right) \\ &&\quad = \left( \frac{1}{L}e^{2\gamma_{\max}t}\cos(k_{\max}(x-x^{\prime}))\right)\left( \frac{1}{\sqrt{\pi|\gamma^{\prime\prime}_{\max}| t}} e^{-\frac{(x-x^{\prime})^{2}}{4|\gamma^{\prime\prime}_{\max}| t}}\right). \end{array} $$
(10)

A typical realization of ρ 1(t,x) is a modulation with the carrier spatial frequency \(k_{\max }\) and a slowly varying envelope with stationary Gaussian statistics, mean zero, and Gaussian covariance function. This is valid provided \(L^{2} \gg 4|\gamma ^{\prime \prime }_{\max }| t\). If \(L^{2} \ll 4|\gamma ^{\prime \prime }_{\max }| t\), then the continuum approximation is not valid and we have

$$\begin{array}{@{}rcl@{}} \mathbb E[\rho_{1}(t,x) \rho_{1}(t,x^{\prime})] &=& \frac{1}{L^{2}} \sum\limits_{k\neq 0} e^{2\gamma_{k} t} e^{ik(x-x^{\prime})} = \frac{2}{L^{2}} \sum\limits_{k>0} e^{2\gamma_{k} t} \cos(k(x-x^{\prime}))\\ &\simeq& \frac{2}{L^{2}} e^{2 \gamma_{\max} t} \cos \left( k_{\max} (x-x^{\prime})\right). \end{array} $$
(11)

A typical realization of ρ 1(t,x) is a modulation with the carrier spatial frequency \(k_{\max }\).

Because \(\gamma _{\max }>0\), the linear system (9) is unstable and therefore the central limit theorem cannot be extended to arbitrarily large times. In fact, the theorem is limited to times t such that \(\rho _{1}(t,x)/\sqrt {N}\) is smaller than ρ 0=1/L so that the linearization around ρ 0 is valid. Therefore, the time up to the onset of clustering is when the perturbation ρ 1 becomes of the same order as \(\sqrt {N} \rho _{0}\), that is to say when \(\mathbb E \big [\rho _{1}(t_{\text {clu}},x)^{2}\big ] \simeq N L^{-2}\), which is approximately (up to terms smaller than \(\ln N\))

$$t_{\text{clu}} \simeq \frac{1}{2 \gamma_{\max} } \ln N \simeq \frac{1}{2 \rho_{0} R_{0} \psi(q_{\max} )} \ln N $$

when N≫1.

We note that the fact that a random initial distribution gives rise to a quasi-deterministic subsequent evolution by spectral gain selection occurs in many fields, for instance in fluid mechanics (hydrodynamic instabilities) or in nonlinear optics (beam filamentation).

4.3 Consensus Convergence

The linear stability analysis shows that the opinion dynamics, starting from a uniform distribution of agents, gives clustering with a mean distance between clusters equal to \(2\pi /k_{\max }\) (see (10) and (11)). Once clustering has occurred, two types of dynamical evolutions are possible:

  1. 1.

    If \(2\pi /k_{\max } > R_{0}\), then the clusters do not interact with each other because they are beyond the range of the influence function. Therefore, the situation is frozen and there is no consensus convergence.

  2. 2.

    If \(2\pi /k_{\max } < R_{0}\), then the clusters interact with each other. There may be consensus convergence. However, consensus convergence is not guaranteed as clusters may merge by packets, and the centers of the new clusters may be separated by a distance larger than \(2\pi / k_{\max }\), and then global consensus convergence does not happen. The number of mega-clusters formed by this dynamic is not easy to predict.

If we neglect the rounding and consider \(k_{\max } = q_{\max } /R_{0}\), which is possible if \(q_{\max } L/R_{0} \gg 1\), then the criterion \(2\pi /k_{\max } >\) or <R 0 does not depend on R 0, as it reads \(2\pi / q_{\max } >\) or <1, which depends only on the normalized influence function ϕ 0 by (7) and (8).

These two dynamics can be observed in the examples of Figure 1.1 in [22]:

  1. 1.

    If ϕ(r) = 1 [0,1](r), then \(q_{\max }\simeq 2.75\) and the mean distance between clusters is about 2.3, that is beyond the range 1 of the influence function, and there is no consensus convergence.

  2. 2.

    If \(\phi (r)=0.1\times \mathbf {1}_{[0,1/\sqrt {2}]}(r)+\mathbf {1}_{[1/\sqrt {2},1]}(r)\), then \(q_{\max }\simeq 9.1\) and the mean distance between clusters is about 0.7, that is within the range of the influence function, and there is consensus convergence.

These predictions are quantitatively in very good agreement with the numerical simulations (distance between clusters and so on).

To summarize, the main result in the noiseless case σ=0 is as follows. In the regime \(N \to \infty \), there is no consensus convergence if \(q_{\max } < 2\pi \). There may be consensus convergence if \(q_{\max } > 2\pi \). Of course this stability analysis and the result that follow can be extended easily to the multi-dimensional case, and to other types of opinions or flocking dynamics.

4.4 Numerical Simulations

We use the explicit Euler scheme to simulate the deterministic opinion dynamic (1) when σ=0

$$ x_{i}^{n+1} = {x_{i}^{n}}-\frac{1}{N} \sum\limits_{j=1}^{N} \phi(|{x_{i}^{n}}-{x_{j}^{n}}|) ({x_{i}^{n}}-{x_{j}^{n}}) {\Delta} t,\quad \phi(s) = \phi_{0}(s/R_{0}). $$
(12)

Although our analysis is on the torus [0,L], we still simulate (12) on the full space. The simulation results indicate, however, that the analysis under periodic conditions is still consistent with the numerics with different boundary conditions. As it is shown in [16, 22], if x 1(0),…,x N (0) are in the interval [0,L], then x 1(t),…,x N (t)∈[0,L] for any t≥0.

We test for the influence functions studied in [16, 22]:

$$\begin{array}{@{}rcl@{}} {\phi_{0}^{1}}(s) &=& \mathbf{1}_{[0,1/\sqrt{2}]}(s) + 0.1\times\mathbf{1}_{(1/\sqrt{2}, 1]}(s),\\ {\phi_{0}^{2}}(s) &=& \mathbf{1}_{[0,1]}(s),\\ {\phi_{0}^{3}}(s) &=& 0.5\times\mathbf{1}_{[0,1/\sqrt{2}]}(s) + \mathbf{1}_{(1/\sqrt{2}, 1]}(s),\\ {\phi_{0}^{4}}(s) &=& 0.1\times\mathbf{1}_{[0,1/\sqrt{2}]}(s) + \mathbf{1}_{(1/\sqrt{2}, 1]}(s),\\ {\phi_{0}^{5}}(s) &=& (1-s)^{3}\times\mathbf{1}_{[0,1]}(s),\\ {\phi_{0}^{6}}(s) &=& (1-s)^{6}\times\mathbf{1}_{[0,1]}(s), \end{array} $$

and their plots are shown in Fig. 1.

Fig. 1
figure 1

The plots of the influence functions ϕ 0(s)

We compute the key quantity \(q_{\max }\) by exploring all possible q in [0,100]:

$$q_{\max} = \underset{R_{0}q\in\mathcal{K},~ 0<q\leq 100}{\arg\max} \left[2q {{\int}_{0}^{1}} \phi_{0}(s) s \sin(q s) ds\right]. $$

We find that for the cases of \({\phi _{0}^{3}}\) and \({\phi _{0}^{4}}\), \(q_{\max }\) are not unique and the non-uniqueness of \(q_{\max }\) will greatly affect the results of the consensus convergence. The parameters we use for the simulation are Δt=0.1, L=10, R 0=1, and N=500. For each ϕ 0, we also plot the function \(\psi (s)=2q{{\int }_{0}^{1}} \phi _{0}(s) s \sin (qs) ds\); the stars in the plots are the values of ψ(s) at \(R_{0}q\in \mathcal {K}\) and the lines are the continuum approximation.

From Fig. 2, we can see that there is a unique \(q_{\max }=3.7699\). From our analysis, we do not expect to have consensus convergence because \(q_{\max }=3.7699<2\pi \). The distance between clusters is \(2\pi R_{0}/q_{\max }=1.67\), and therefore we should have roughly L/1.67=5.99 clusters, and indeed we have 6 clusters in our simulation. In addition, \(t_{\text {clu}}=\ln N/(2\rho _{0}R_{0}\psi (q_{\max }))=21\) (the vertical blue dashed line) also correctly predicts the time to cluster formation.

Fig. 2
figure 2

Simulation for \(\phi _{0}(s)={\phi ^{1}_{0}}(s)\). Left: ψ(q) evaluated at \(R_{0}q\in \mathcal {K}\). Right: Simulations of (12). The vertical dashed line is at t = t clu

In Fig. 3, if ϕ 0(s) = 1 [0,1](s), then ψ(q) has a unique \(q_{\max }=2.51\) but it also has many suboptimal q where ψ(q) is very close to \(\psi (q_{\max })\). Note that \(q_{\max }<2\pi \) means that there is no consensus convergence. The inter-cluster distance is 2.5, which is correct for the top and the bottom clusters. However, the central clusters are affected by the suboptimal q and therefore their inter-cluster distances are different. We also note that \(t_{\text {clu}}=\ln N/(2\rho _{0}R_{0}\psi (q_{\max }))=14.9\) (the vertical blue dashed line) correctly estimates the time to the formation of the top and bottom clusters.

Fig. 3
figure 3

Simulation for \(\phi _{0}(s)={\phi ^{2}_{0}}(s)\). Left: ψ(q) evaluated at \(R_{0}q\in \mathcal {K}\). Right: Simulations of (12). The vertical dashed line is at t = t clu

We see an interesting result in Fig. 4 for \(\phi _{0}(s)=0.5\times \mathbf {1}_{[0,1/\sqrt {2}]}(s) + \mathbf {1}_{(1/\sqrt {2}, 1]}(s)\). From the plot of ψ(q), we can see that \(q_{\max }\) might not be unique and the first few local maximizers are q=2.5133, 9.4248, 15.7080,…, and the corresponding inter-cluster distances are 2.5, 0.6667, 0.4000,…. We can see from the simulation that there are two noticeable inter-cluster distances: 2.5 and 0.6667. For \(R_{0}q\in \mathcal {K}\), 0≤q≤100, \(q_{\max }=53.4071\) so that the necessary condition to have the consensus convergence \(q_{\max }>2\pi \) is satisfied. However, we do not have consensus convergence in this case because \(q_{\max }>2\pi \) is not a sufficient condition. We notice that although \(q_{\max }\) might not be unique, t clu=11.5 still predicts the time to cluster formation because it is related to \(\psi (q_{\max })\) not \(q_{\max }\) and thus the non-uniqueness of \(q_{\max }\) does not affect t clu.

Fig. 4
figure 4

Simulation for \(\phi _{0}(s)={\phi ^{3}_{0}}(s)\). Left: ψ(q) evaluated at \(R_{0}q\in \mathcal {K}\). Right: Simulations of (12). The vertical dashed line is at t = t clu

In Figs. 5 and 6, we see consensus convergence. From the plot of ψ(q), we can see that \(q_{\max }\) might not be unique and the first few local maximizers are q=2.5133, 9.4248, 16.3363,…, and the corresponding inter-cluster distances are 2.5, 0.6667, 0.3846,…. In this case, the only noticeable inter-cluster distance is 0.6667 and we do not observe the inter-cluster distance of 2.5, because ψ(2.5133)≪ψ(9.4248). For \(R_{0}q\in \mathcal {K}\), 0≤q≤100, \(q_{\max }=53.4071\) so that the necessary condition to have the consensus convergence \(q_{\max }>2\pi \) is satisfied and indeed we see from Fig. 6 that we have consensus convergence in this case.

Fig. 5
figure 5

Simulation for \(\phi _{0}(s)={\phi ^{4}_{0}}(s)\). Left: ψ(q) evaluated at \(R_{0}q\in \mathcal {K}\). Right: Simulations of (12) for t≤150. The vertical dashed line is at t = t clu

Fig. 6
figure 6

Simulation for \(\phi _{0}(s)={\phi ^{4}_{0}}(s)\). Simulations of (12) for t≤1000

In Fig. 7, we choose ϕ 0(s) so that ψ(s) has a unique local maximum and \(q_{\max }=5.0265\). In this case, \(q_{\max }<2\pi \) and therefore there is no consensus convergence. The inter-distance is 1.25 and L/1.25=8 which is exactly the number of clusters in this case. Again, t clu predicts the time to cluster formation very well.

Fig. 7
figure 7

Simulation for \(\phi _{0}(s)={\phi ^{5}_{0}}(s)\). Left: ψ(q) evaluated at \(R_{0}q\in \mathcal {K}\). Right: Simulations of (12). The vertical dashed line is at t = t clu

Finally, Fig. 8 considers ϕ 0(s) so that ψ(s) has a unique local maximum, but with a larger exponent, \(q_{\max }=8.1681>2\pi \). The inter-cluster distance corresponding to \(q_{\max }=8.1681\) is 0.769, which is consistent with the actual inter-cluster distance. The quantity L/0.769=13 gives a good approximation for the actual number of clusters, which is 11. As in all the previous cases, t clu=185 predicts the time to cluster formation well. Here, \(q_{\max }>2\pi \), so we could expect to observe consensus convergence. However, the inter-cluster distance 0.769 is such that ϕ(0.769)∼10−4, so we cannot see cluster evolution for the time horizon of the simulation.

Fig. 8
figure 8

Simulation for \(\phi _{0}(s)={\phi ^{6}_{0}}(s)\). Left: ψ(q) evaluated at \(R_{0}q\in \mathcal {K}\). Right: Simulations of (12). The vertical dashed line is at t = t clu

5 Stochastic Consensus Convergence: σ>0

In this section, we consider the case that σ>0 in (1). In other words, the system is stochastic and we are dealing with a nonlinear Fokker–Planck equation.

5.1 Linear Stability Analysis

As in the deterministic case, we linearize the Fokker–Planck equation (3) with σ>0 by assuming that ρ(t,x) = ρ 0 + ρ 1(t,x)=1/L + ρ 1(t,x). Substituting ρ(t,x) = ρ 0 + ρ 1(t,x) into (3) and assuming that ρ 1 is a small perturbation of ρ so that the \(O({\rho _{1}^{2}})\) term is negligible, we find that ρ 1(t,x) satisfies

$$ \frac{\partial \rho_{1}}{\partial t}(t,x) = \rho_{0} \int \frac{\partial \rho_{1}}{\partial x}(t,x-y) y \phi(|y|) dy + \frac{\sigma^{2}}{2} \frac{\partial^{2} \rho_{1}}{\partial x^{2}}(t,x). $$

In the Fourier domain:

$$ \frac{\partial \hat{\rho}_{1}}{\partial t}(t,k) = \left[ i \rho_{0} k \int e^{-iky} y \phi(|y|) dy - \frac{\sigma^{2} k^{2}}{2} \right]\hat{\rho}_{1} (t,k), $$
(13)

which gives the growth rates of the modes

$$ \gamma_{k} = \text{Re} \left[ i \rho_{0} k \int e^{-iky} y \phi(|y|) dy - \frac{\sigma^{2} k^{2}}{2} \right] = \rho_{0} k \int \sin(ky) y \phi(|y|) dy - \frac{\sigma^{2} k^{2}}{2}. $$
(14)

We can rewrite the growth rate γ k = ρ 0 R 0 ψ σ (k R 0), where

$$ \psi_{\sigma}(q) = 2q {{\int}_{0}^{1}} \phi_{0}(s) s \sin(q s) ds - \frac{\sigma^{2} q^{2}}{2 \rho_{0} {R_{0}^{3}}}. $$
(15)

The optimal positive frequency is \(k_{\max }\) that is the element of \(\mathcal {K} = \{2\pi n /L, n \in \mathbb N\}\) that maximizes ψ σ (k R 0), that is close to \(q_{\max }/R_{0}\), where

$$q_{\max}=\underset{q>0}{\arg\max}\left[\psi_{\sigma}(q)\right]. $$

There is a critical value σ c of σ such that the system has a completely different overall behavior for σ<σ c and for σ>σ c . We can view σ as the magnitude of the noise energy or temperature of the system. There are two types of forces in the system (1): the attractive interaction −a i j (x i x j ) and the random force σ d W i(t). If σ<σ c , then the attractive interaction dominates the random force and thus the system is a perturbation of the deterministic system. If σ>σ c , then the random force dominates, the attractive interaction is negligible, and therefore the overall system behaves like a system of N independent random processes.

The above observations can be articulated mathematically. Let

$$\begin{array}{@{}rcl@{}} {\sigma_{c}^{2}} &=& \underset{q>0}{\max} \left[\frac{4\rho_{0} {R_{0}^{3}}}{q}{{\int}_{0}^{1}} \phi_{0}(s) s \sin(qs) ds\right]\\ &=& \underset{q>0}{\max} \left[4\rho_{0} {R_{0}^{3}}{{\int}_{0}^{1}} \phi_{0}(s) s^{2} \frac{\sin(qs)}{qs} ds\right] = 4 \rho_{0} {R_{0}^{3}} {{\int}_{0}^{1}} s^{2} \phi_{0}(s)ds. \end{array} $$

If σ<σ c , then from (15) we find that

$$\max_{q>0}\psi_{\sigma}(q) > 0, $$

and \(\hat {\rho }(t,k_{\max })\) has positive growth rate \(\gamma _{\max } = \rho _{0} R_{0} \psi _{\sigma }(k_{\max } R_{0})\). The linear system (13) is unstable, which is analogous to the deterministic case.

If σ>σ c , then all of \(\hat {\rho }(t,k)\) have negative growth rates. In other words, the constant density is linearly stable and therefore the overall system is stable, since this is what linear stability implies in this case.

We note that the same technique for computing σ c , with linear stability analysis for different noisy opinion models, is also used in [2325].

5.2 Fluctuation Theory

Since our goal is to analyze the behavior of clusters, we suppose from now on that σ<σ c .

The fluctuation analysis of the stochastic model is similar to that of the deterministic case. If x 1(0),…,x N (0) are independent, uniform random variables in [0,L], then

$${\rho^{N}_{1}}(t=0,dx) := \sqrt{N} \left( \rho^{N}(t=0,dx) - \rho_{0}(dx) \right) = \sqrt{N} \left( \frac{1}{N} \sum\limits_{j=1}^{N}\delta_{x_{j}(0)}(dx) - \frac{dx}{L} \right) $$

converges in distribution as \(N \to \infty \) to the measure ρ 1(t=0,d x), whose frequency components

$$\hat{\rho}_{1}(t=0,k) = \lim_{N\to\infty} \sqrt{N} \left( \frac{1}{N}\sum\limits_{j=1}^{N} e^{-ikx_{j}(0)}\right) $$

are independent complex circular Gaussian random variables, with mean zero and variance 1 for \(k \in \mathcal K\backslash \{0\}\)

$$\mathbb E\left[ \hat{\rho}_{1}(t=0,k) \right]=0,\quad \mathbb E\left[ \hat{\rho}_{1}(t=0,k) \overline{\hat{\rho}_{1}(t=0,k^{\prime})} \right] = \delta_{kk^{\prime}},\quad k,k^{\prime} \in \mathcal K \backslash \{0\}, $$

\(\hat {\rho }_{1}(t=0,-k) = \overline {\hat {\rho }_{1}(t=0,k) }\), while \(\hat {\rho }_{1}(t=0,k=0) =0\).

For any \(T<\infty \), the measure-valued process

$${\rho^{N}_{1}}(t,dx) := \sqrt{N} \left( \rho^{N}(t,dx) - \rho_{0}(dx) \right), \quad t \in [0,T] $$

converges in distribution as \(N \to \infty \) to a measure-valued process ρ 1(t,d x) whose density ρ 1(t,x) satisfies a stochastic PDE (see [8])

$$ d\rho_{1} (t,x) = \left[\rho_{0} \int \frac{\partial \rho_{1}}{\partial x}(t,x-y) y \phi(|y|) dy + \frac{\sigma^{2}}{2} \frac{\partial^{2} \rho_{1}}{\partial x^{2}} (t,x)\right] dt + \sigma d W(t,x) $$
(16)

with the random initial condition described above. Here, W(t,x) is a space-time Gaussian random noise with mean zero and covariance

$$ \text{Cov}\left( {{\int}_{0}^{L}} W(s,x) f_{1}(x) dx, \overline{{{\int}_{0}^{L}} W(t,x) f_{2}(x) dx}\right) = \frac{\min\{s,t\}}{L} {{\int}_{0}^{L}} f^{\prime}_{1}(x) \overline{f^{\prime}_{2}(x)}dx $$
(17)

for any test functions f 1(x) and f 2(x). The Fourier transform of W(t,x) is \(\hat {W}(t,k) = {{\int }_{0}^{L}} W(t,x) e^{-ikx} dx\) for \(k\in \mathcal K\). From (17), we see that \(\{\hat {W}(t,k), k\in \mathcal K, k \geq 0\}\) are independent, complex-valued Brownian motions with the variance

$$ \text{Cov} \left( \hat{W}(t,k), \overline{\hat{W}(t,k)}\right) = \frac{t}{L} {{\int}_{0}^{L}} (-ik)e^{-ikx} \overline{(-ik)e^{-ikx}} dx = t k^{2}, $$

and \(\hat {W}(t,-k)= \overline {\hat {W}(t,k)}\). Taking the Fourier transform on (16), for each \(k\in \mathcal K\), \(\hat {\rho }_{1}(t,k) = {{\int }_{0}^{L}} \rho _{1}(t,x) e^{-ikx} dx\) is a complex-valued Ornstein–Uhlenbeck (OU) process

$$ d\hat{\rho}_{1} (t,k) = \left[ i \rho_{0} k {{\int}_{0}^{L}} e^{-iky} y \phi(|y|) dy - \frac{\sigma^{2} k^{2}}{2} \right]\hat{\rho}_{1} (t,k) dt + \frac{\sigma k}{\sqrt{2}} d (W^{(k)}(t) + i \tilde{W}^{(k)}(t)). $$
(18)

Here, \(\{W^{(k)}(t), k\in \mathcal K, k>0\}\) and \(\{\tilde {W}^{(k)}(t), k\in \mathcal K, k>0\}\) are independent real Brownian motions, \(W^{(0)}(t)=\tilde {W}^{(0)}(t)=0\), W (−k)(t)=−W (k)(t), and \(\tilde {W}^{(-k)}(t)=\tilde {W}^{(k)}(t)\). The equation (18) is solvable and we have, for any \(k \in \mathcal K\backslash \{0\}\),

$$\begin{array}{@{}rcl@{}} \hat{\rho}_{1} (t,k) &=& e^{\alpha_{k} t} \hat{\rho}_{1} (0,k) + \frac{\sigma k}{\sqrt{2}} {{\int}_{0}^{t}} e^{\alpha_{k} (t-s)} d (W^{(k)}(s)+ i \tilde{W}^{(k)}(s)),\\ \alpha_{k} &=& i \rho_{0} k {{\int}_{0}^{L}} e^{-iky} y \phi(|y|) dy - \frac{\sigma^{2} k^{2}}{2}. \end{array} $$

In particular, \(\hat {\rho }_{1}(t,k=0)=0\). Because \(\{\hat {\rho }_{1} (0,k), W^{(k)}(t), \tilde {W}^{(k)}(t), k\in \mathcal K, k>0\}\) are independent, \(\{\hat {\rho }_{1} (t,k), k\in \mathcal K, k>0\}\) are independent OU processes with mean zero and variance

$$ \mathbb E \left[ \hat{\rho}_{1}(t,k) \overline{\hat{\rho}_{1}(t,k)} \right] = e^{2 \gamma_{k} t} + \sigma^{2} k^{2} {{\int}_{0}^{t}} e^{2\gamma_{k} (t-s)} ds = e^{2 \gamma_{k} t}\left[1 + \frac{\sigma^{2} k^{2}}{2\gamma_{k}}\right] $$

for \(k\in \mathcal K\), k>0, where γ k is the real part of α k . In addition, because \(\alpha _{-k} = \overline {\alpha _{k}}\) and W (−k)(t)=−W (k)(t), we have \(\hat {\rho }_{1}(t,-k) = \overline {\hat {\rho }_{1}(t,k)}\) for \(k\in \mathcal K\backslash \{0\}\). Finally, \(\hat {\rho }_{1}(t,0) = 0\). Therefore,

$$\begin{array}{@{}rcl@{}} &&\mathbb E\left[\rho_{1}(t,x)\rho_{1}(t,x^{\prime})\right] = \mathbb E\left[\sum\limits_{k}\hat{\rho}_{1}(t,k)\frac{e^{ikx}}{L} \sum\limits_{k}\hat{\rho}_{1}(t,k)\frac{e^{ikx^{\prime}}}{L}\right]\\ &&\quad = \sum\limits_{k} \mathbb E\left[\hat{\rho}_{1}(t,k)\frac{e^{ikx}}{L} \hat{\rho}_{1}(t,-k)\frac{e^{-ikx^{\prime}}}{L}\right] = \frac{1}{L^{2}} \sum\limits_{k\neq 0} e^{2 \gamma_{k} t}e^{ik(x-x^{\prime})}\left[1 + \frac{\sigma^{2} k^{2}}{2\gamma_{k}}\right]. \end{array} $$

As t increases, the spectrum of ρ 1(t,x) becomes concentrated around the optimal wavenumber \(k_{\max }\). In addition, we note that k 2/γ k is bounded and the term σ 2 k 2/γ k is negligible if σ is sufficiently small. We can assume σ is small because we need σ<σ c for cluster formation. If σ 2 k 2/γ k is negligible and \(L^{2} \gg 4|\gamma ^{\prime \prime }_{\max }| t\), we can expand \(\gamma _{k} = \gamma _{\max } + \frac {1}{2} \gamma ^{\prime \prime }_{\max } (k-k_{\max })^{2}\) for k around \(k_{\max }\), and use a continuum approximation for the discrete sum as we do in the deterministic case

$$\mathbb E\left[\rho_{1}(t,x)\rho_{1}(t,x^{\prime})\right] \simeq \left( \frac{1}{L}e^{2\gamma_{\max}t}\cos(k_{\max}(x-x^{\prime}))\right) \left( \frac{1}{\sqrt{\pi|\gamma^{\prime\prime}_{\max}| t}} e^{-\frac{(x-x^{\prime})^{2}}{4|\gamma^{\prime\prime}_{\max}| t}}\right). $$

If \(L^{2} \ll 4|\gamma ^{\prime \prime }_{\max }| t\), then the continuum approximation is not valid and in this case

$$\mathbb E \left[\rho_{1}(t,x) \rho_{1}(t,x^{\prime}) \right] \simeq \frac{2}{L^{2}} e^{2 \gamma_{\max} t} \cos \left( k_{\max} (x-x^{\prime})\right) \left[1 + \frac{\sigma^{2} k_{\max}^{2}}{2\gamma_{\max}}\right]. $$

Because σ<σ c we have that \(\gamma _{\max }>0\) and then the linear system (16) is unstable and therefore the central limit theorem breaks down when \(\rho _{1}(t,x)/\sqrt {N}\) is no longer smaller than ρ 0=1/L. More precisely, the time t clu for the onset of clustering is when \(\mathbb E \big [ \rho _{1}(t_{\text {clu}},x)^{2} \big ] \simeq N L^{-2}\), which is approximately

$$t_{\text{clu}} \simeq \frac{1}{2 \gamma_{\max} } \ln N \simeq \frac{1}{2 \rho_{0} R_{0} \psi_{\sigma}(q_{\max} )} \ln N $$

when N≫1.

5.3 Consensus Convergence

We assume σ<σ c so that there are unstable modes for the linearized evolution, which means that there is clustering. The number of and the distance between clusters can be estimated with \(q_{\max }\). We find that the first term of the right-hand side of (15) is bounded while the second term of (15) is quadratic with negative leading coefficient. Therefore, increasing σ tends to reduce \(q_{\max }\), that is to say, to increase the mean distance between clusters.

Let us consider the case that \(q_{\max } < 2\pi \). From the analysis of the deterministic case, the system initially has no consensus convergence and there are several clusters. After clustering, the clusters do not interact with each other, but their centers move like independent Brownian motions. When two clusters come close to each other, within a distance R 0, they interact and merge. Therefore, we will eventually have consensus convergence, because two Brownian motions always collide in \(\mathbb R\). This can be extended to the multi-dimensional case, but then the conclusion can be different: in high dimension two Brownian motions may not collide. However, with periodic boundary conditions, two Brownian motions will always come close to each other, within a distance R 0.

When \(q_{\max } < 2\pi \) and σ is small then there are several clusters, after the cluster formation time. The fraction of agents in a cluster is the agent density times the inter-distance of the clusters

$$m_{c} = \rho_{0}\frac{ 2\pi R_{0}}{q_{\max}} = \rho_{0}\frac{ 2\pi }{k_{\max}}. $$

Then the jth cluster consists of about N m c agents. We assume that σ is small enough so that \(\sigma ^{2} k_{\max } \ll 2 \pi \rho _{0} \phi _{0}(0) {R_{0}^{2}}\). By using the fact that the agents in a cluster stay close to each other, we can replace ϕ(x i x j ) by ϕ(0), and the agents in the jth cluster have the approximate dynamics

$$dx^{(j)}_{i} = -\frac{\phi_{0}(0)}{N} \sum\limits_{l=1}^{Nm_{c}}\left( x^{(j)}_{i}-x^{(j)}_{l}\right) dt+ \sigma dW^{(j,i)}(t). $$

The center \(X^{(j)}(t)=\frac {1}{Nm_{c}}{\sum }_{i=1}^{Nm_{c}}x^{(j)}_{i}(t)\) satisfies

$$ X^{(j)}(t) = X^{(j)}(0) + \frac{\sigma}{\sqrt{Nm_{c}}} W^{(j)}(t), $$
(19)

where {W (j)(t)} are independent standard Brownian motions.

When N is large, the empirical density \(\frac {1}{Nm_{c}}{\sum }_{i=1}^{Nm_{c}}\delta _{x^{(j)}_{i}}(dx)\) is approximately a Gaussian density

$$ \rho^{(j)} (t,dx) = \frac{1}{\sqrt{\pi(\sigma^{(j)})^{2}}} \exp \left( - \frac{(x-X^{(j)}(t))^{2}}{(\sigma^{(j)})^{2}}\right)dx, \quad \sigma^{(j)} = \frac{\sigma}{\sqrt{ m_{c} \phi_{0}(0)}}. $$
(20)

For this argument to be valid, we must have that σ (j), the width of ρ (j), is much smaller than R 0, which is equivalent to our assumption \(\sigma ^{2} k_{\max } \ll 2 \pi \rho _{0} \phi _{0}(0) {R_{0}^{2}}\).

This cluster dynamics is valid as long as the centers {X (j)(t)} stay away from each other by a distance larger than R 0. The clusters move, according to independent Brownian motions with quadratic variation \(\frac {\sigma ^{2} t}{Nm_{c}}\). When two clusters come close to each other within a distance R 0, they merge. Indeed, once the two centers are within distance R 0, they obey the following differential equations to leading order in N

$$\begin{array}{@{}rcl@{}} \frac{d X^{(k)}(t)}{dt} &=& - m_{c} \left( X^{(k)}(t) - X^{(l)}(t)\right) \phi\left( X^{(k)}(t) - X^{(l)}(t)\right),\\ \frac{d X^{(l)}(t)}{dt} &=& - m_{c} \left( X^{(l)}(t) - X^{(k)}(t)\right) \phi\left( X^{(k)}(t) - X^{(l)}(t)\right), \end{array} $$

which shows that the inter-cluster distance converges exponentially fast to zero and the center converges to the average of the centers just before collision. The number of agents or mass of the new cluster is the sum of the masses of the two clusters, the inverse square width of its empirical density is the sum of the inverse squares of the two widths, its center is at the weighted average (weighted by the masses) of the two centers just before collision and it moves as a Brownian motion whose diffusion constant is defined in terms of its new mass. Then, the cluster centers move according to Brownian motions until two of them get within the distance R 0 from each other and a new merge event occurs. This eventually forms a Markovian dynamics described in the next section.

5.4 Markovian Dynamics of the Clusters

After the initial clusters are formed, we can use an iterative argument to mathematically describe how all the opinions converge eventually. In the initial configuration, at time τ 0, there are \(M(\tau _{0}) = L k_{\max } / 2\pi \) clusters with centers \(X^{(j)}(\tau _{0}) = j 2 \pi /k_{\max }\) (up to a global shift), widths \(\sigma ^{(j)}(\tau _{0})=\sigma /\sqrt {m_{c} \phi _{0}(0)}\), and masses m (j)(τ 0) = m c for j=1,…,M(τ 0).

For tτ n−1, there are M(τ n−1) clusters moving as

$$X^{(j)}(t) = X^{(j)}(\tau_{n-1}) + \sigma^{(j)}(\tau_{n-1}) \frac{\sqrt{\phi_{0}(0)}}{\sqrt{N}} \left( W^{(j)}(t) - W^{(j)}(\tau_{n-1}) \right) $$

until the stopping time

$$\tau_{n} = \inf \left\{ t > \tau_{n-1}: |X^{(k)}(t) -X^{(l)}(t) | = R_{0}~ \text{ for some } k\neq l\right\}. $$

Then the two colliding clusters (with indices k and l) merge with the new center

$$\tilde{X}(\tau_{n}^{+}) = \frac{m^{(k)}(\tau_{n-1}) X^{(k)}(\tau_{n}^{-}) + m^{(l)}(\tau_{n-1}) X^{(l)}(\tau_{n}^{-})}{m^{(k)}(\tau_{n-1}) + m^{(l)}(\tau_{n-1})}, $$

the new mass

$$\tilde{m}(\tau_{n}) = m^{(k)}(\tau_{n-1}) + m^{(l)}(\tau_{n-1}) $$

and the new width

$$\tilde{\sigma} (\tau_{n} ) = \frac{\sigma}{\sqrt{\tilde{m}(\tau_{n}) \phi_{0}(0)}}. $$

The clusters are relabeled to take into account this merging so that there are M(τ n ) = M(τ n−1)−1 clusters. The above process is repeated until \(n=(L k_{\max } / 2\pi )-1\), when we have only one cluster, and hence consensus convergence.

Note that the time scale at which collisions and merges occur is of the order of N, as the Brownian motions are scaled by \(1/\sqrt {N}\).

5.5 Numerical Simulations

We use the explicit Euler scheme to simulate the stochastic opinion dynamics (1) when σ>0:

$$ x_{i}^{n+1} ={x_{i}^{n}} -\frac{1}{N} \sum\limits_{j=1}^{N} \phi(|{x_{i}^{n}}-{x_{j}^{n}}|) ({x_{i}^{n}}-{x_{j}^{n}}) {\Delta} t + \sigma {\Delta} W^{n+1}_{i},\quad \phi(s) = \phi_{0}(s/R_{0}), $$
(21)

where \(\{W^{n+1}_{i}\}\) are independent Gaussian random variables with mean zero and variance Δt.

Our analysis is on the torus [0,L], but we simulate (21) on [0,L] with reflecting boundary conditions. As we will see, the simulation results agree with the analysis under periodic assumption. Because here, we focus on the effects of the randomness, for simplicity we will work only on the case that ϕ 0(s) = 1 [0,1](s).

We compute the key quantity \(q_{\max }\) by exploring all possible q in [0,100]

$$q_{\max} = \underset{R_{0}q\in\mathcal{K},~ 0<q\leq 100}{\arg\max} \left[2q {{\int}_{0}^{1}} \phi_{0}(s) s \sin(q s) ds - \frac{\sigma^{2} q^{2}}{2 \rho_{0} {R_{0}^{3}}}\right]. $$

We see from the plots of ψ σ (s) that the randomness reduces the possibility of the non-uniqueness of \(q_{\max }\) because it adds a negative quadratic term in ψ σ (s). With randomness, all of our test cases have a clear, unique \(q_{\max }\).

The parameters we use for the simulation are Δt=0.1, L=10, R 0=1, and N=500. For each σ, we also plot the function ψ σ (s) in (15); the stars in the plots are the values of ψ(s) evaluated at \(R_{0}q\in \mathcal {K}\) and the lines are the continuum approximation.

We first to test for the effect of σ c , the critical value for σ, which makes the system stable or unstable. In our setting, \(\sigma _{c}=4 \rho _{0} {R_{0}^{3}} {{\int }_{0}^{1}} s^{2} \phi _{0}(s)ds = 0.365\) and we simulate (21) for σ=0.1,0.2,0.365,0.5 that are values below, equal to and above σ c , respectively.

From Fig. 9, we see that ψ σ (q) decreases quadratically and has the unique maximum at q=2.5133. However, \(\max _{R_{0}q\in \mathcal {K}}\psi _{\sigma }(q)\) is still positive so the linearized system (13) is still unstable. Therefore, the overall system behavior is similar to the deterministic case and can be viewed as a perturbed non-random opinion dynamics.

Fig. 9
figure 9

Simulations for σ=0.1. Left: ψ σ (q) evaluated at \(R_{0}q\in \mathcal {K}\). Right: Simulations of (21). The vertical dashed line is at t = t clu

We increase σ by setting σ=0.2 and the result is in Fig. 10. We see that as σ increases, the random noise starts to affect the overall system, and the width and the inter-cluster distances become larger so we observe fewer clusters. Since \(\max _{R_{0}q\in \mathcal {K}}\psi _{\sigma }(q)\) is positive, we still observe cluster formation.

Fig. 10
figure 10

Simulations for σ=0.2. Left: ψ σ (q) evaluated at \(R_{0}q\in \mathcal {K}\). Right: Simulations of (21)

We note that in Figs. 11 and 12, if σσ c , ψ σ (q)<0 for all q>0 and ψ σ (0)=0. In other words, the linearized system is stable and thus the full system is stable. In this case, we do not see cluster formation and the system behaves like an N-independent agent system.

Fig. 11
figure 11

Simulations for σ = σ c . Left: ψ σ (q) evaluated at \(R_{0}q\in \mathcal {K}\). Right: Simulations of (21)

Fig. 12
figure 12

Simulations for σ=0.5. Left: ψ σ (q) evaluated at \(R_{0}q\in \mathcal {K}\). Right: Simulations of (21)

We see from the simulations that to model opinion dynamic with consensus convergence it is appropriate to assume that σ<σ c . Therefore, we will assume that σ=0.1 in our simulations of the stochastic system.

We revisit Fig. 9 to check our analysis. First of all, \(q_{\max }=2.5133\) is clearly a unique maximizer and the corresponding inter-cluster distance is 2.51, which agrees with the numerical inter-cluster distance we see in Fig. 9. In addition, L/2.51=3.9841 also predicts well the actual number of the clusters, 4. Finally, the blue dashed line t = t c l u indicates the time to the cluster formation, even though Fig. 9 is just one realization.

We test t clu and the width of clusters in a more statistical way by examining 1000 realizations. If ϕ 0(s) = 1 [0,1](s) and σ=0.1, then we can expect that we will have 4 clusters at T=150 in most of the realizations. For each realization, we numerically compute the widths of the clusters, \(\hat {\sigma }^{(j)}(t)\), j=1,…,4 by using the empirical standard deviations of \(\{x^{(j)}_{i}(t)\}_{j=1}^{4}\) (see (20))

$$ (\hat{\sigma}^{(j)}(t))^{2} = \frac{2}{N^{(j)}-1}\sum\limits_{i=1}^{N^{(j)}}\left( x^{(j)}_{i}(t)-\bar{x}^{(j)}(t)\right)^{2},\quad \bar{x}^{(j)}(t) = \frac{1}{N^{(j)}}\sum\limits_{i=1}^{N^{(j)}} x^{(j)}_{i}(t), $$
(22)

where for each j=1,…,4, \(\{x^{(j)}_{i}(t)\}\) belong to the jth cluster and N (j) is the number of agents in the jth clusters. Of course, \(\hat {\sigma }^{(j)}(t)\) in (22) is just one realization and so we compute \(\hat {\sigma }^{(j)}(t)\) for 1000 realizations and consider the average.

The averages \(\hat {\sigma }^{(j)}(t)\) are shown in the left part of Fig. 13, in different colors. First, we can see that t clu, as expected, is the halfway from the time to maximum with to the time to the minimum width. Second, from (20), the width of each cluster is analytically \(\sigma ^{(j)} = \sigma /\sqrt { m_{c} \phi _{0}(0)} = 0.1/\sqrt {0.25\times 1}=0.2\), which agrees with the numerical values \(\hat {\sigma }^{(j)}(t)\) when t is large.

Fig. 13
figure 13

Left: Average of 1000 realizations of \(\hat {\sigma }^{(j)}(t)\), j=1,…,4 for σ=0.1. The vertical dashed line is at t = t clu. Right: N (j), the number of agents in the jth clusters in Fig. 9

We also analyze the behavior of the centers of the clusters. The centers \(\{X^{(j)}(t)\}_{j=1}^{4}\) of the clusters in Fig. 9 are plotted in Fig. 14. From the previous analysis (19), the centers of the clusters are independent Brownian motions \(\sigma W^{(j)}(t)/\sqrt {Nm_{c}}\). For one realization, the opinions \(\{x_{i}(t)\}_{i=1}^{N}\) will not be evenly distributed in the clusters. For example, the actual numbers \(\{N^{(j)}\}_{j=1}^{N}\) of agents of the clusters in Fig. 9 are plotted in Fig. 13. So for one realization, X (j)(t) is a Brownian motion \(\sigma W^{(j)}(t)/\sqrt {N^{(j)}}\). On the right part of Fig. 14, we compare the quadratic variations of X (j)(t) and \(\sigma W^{(j)}(t)/\sqrt {N^{(j)}}\) for 75≤t≤150 (after the time to the cluster formation.) Indeed, from the figure, we can see that their quadratic variations are very similar and that means X (j)(t) are very close to Brownian motions.

Fig. 14
figure 14

Left: Centers of the clusters, X (j)(t), in Fig. 9, in different colors. Right: Quadratic variations of the cluster centers from t=75 to t=150. Solid lines: Numerical quadratic variations of X (j)(t). Dashed lines: Quadratic variations of \(\sigma W^{(j)}(t)/\sqrt {N^{(j)}}\), where \(\{W^{(j)}(t)\}_{j=1}^{4}\) are independent standard Brownian motions and \(\{N^{(j)}\}_{j=1}^{4}\) are the numbers of agents in the clusters

6 Long Time Behavior of Simulations

We have also simulated numerically the long time behavior of the system defined on the full real line \(\mathbb {R}\), especially the behavior after the onset of consensus convergence. As we discuss in the previous section, when there is randomness the center of the unique cluster behaves like a diffusion process \(\sigma W(t)/\sqrt {N}\), where W(t) is a standard Brownian motion. In Figs. 15 and 16, we observe that the centers indeed behave like Brownian motions. The dashed lines are the parabolas with equation \(x=\pm 2\sigma \sqrt {t/N}\) so that for any fixed t, the centers are within the parabolas with 95 % probability.

Fig. 15
figure 15

Long time behavior of the opinions for σ=0.1 and for N=100,200. The blue dashed curve is the equation \(x=\pm 2\sigma \sqrt {t/N}\). σ is small and the overall behavior is like a single Brownian motion

Fig. 16
figure 16

Long time behavior of the opinions for σ=0.2 and for N=100,200. The blue dashed curve is the equation \(x=\pm 2\sigma \sqrt {t/N}\). σ is small and the overall behavior is like a single Brownian motion

However, when σ is sufficiently large, the long time behavior is different. On the right part of Fig. 17, when σ=0.4>σ c , the system behaves like N-independent diffusions. A more interesting case is when σ=0.3<σ c on the left part of Fig. 17. In this case, for 0≤t≤5.5×105, there is still consensus convergence, but for t>5.5×105, all x i (t) spread out from the unique cluster and the system becomes an independent agent evolution. A detailed mathematical analysis using large deviations theory for such a phenomenon is being considered at present.

Fig. 17
figure 17

Long time behavior of the opinions for σ=0.3,0.4 and for N=100. The blue dashed curve is the equation \(x=\pm 2\sigma \sqrt {t}\). For σ=0.3, there is a single cluster for t≤5.5×105. However, for t>5.5×105, x i (t) disintegrate and the system behaves like an N-independent Brownian motions. For σ=0.4, the random perturbations are large enough so that the system is an N-independent Brownian motions at the beginning

7 Conclusion

We have analyzed a stochastic, continuous time opinion dynamics model and we have carried out extensive numerical simulations. We use the mean-field theory and obtain a nonlinear Fokker–Planck equation as the number of opinions tends to infinity. Then, we use a linear stability analysis to estimate the critical value of the noise strength so as to have cluster formation, estimate the number of clusters and the time to cluster formation. These quantities are closely related to the frequency that maximizes the growth rate of the linearized modes (14). After the initial cluster formation, we expect, and numerically confirm, that the centers of the clusters behave like Brownian motions before further consolidation. Finally, the long time behavior of the system is explored numerically and we observe that after a unique cluster is formed, there is a small probability that the opinions will spread out from the unique cluster and the system will become an independent agent evolution.