Browse Subject Areas

Click through the PLOS taxonomy to find articles in your field.

For more information about PLOS Subject Areas, click here.

  • Loading metrics

Belief Propagation Algorithm for Portfolio Optimization Problems

  • Takashi Shinzato ,

    Contributed equally to this work with: Takashi Shinzato, Muneki Yasuda

    Affiliation Mori Arinori Center for Higher Education and Global Mobility, Hitotsubashi University, Kunitachi, Tokyo, Japan

  • Muneki Yasuda

    Contributed equally to this work with: Takashi Shinzato, Muneki Yasuda

    Affiliation Graduate School of Science and Engineering, Yamagata University, Yonezawa, Yamagata, Japan

Belief Propagation Algorithm for Portfolio Optimization Problems

  • Takashi Shinzato, 
  • Muneki Yasuda


The typical behavior of optimal solutions to portfolio optimization problems with absolute deviation and expected shortfall models using replica analysis was pioneeringly estimated by S. Ciliberti et al. [Eur. Phys. B. 57, 175 (2007)]; however, they have not yet developed an approximate derivation method for finding the optimal portfolio with respect to a given return set. In this study, an approximation algorithm based on belief propagation for the portfolio optimization problem is presented using the Bethe free energy formalism, and the consistency of the numerical experimental results of the proposed algorithm with those of replica analysis is confirmed. Furthermore, the conjecture of H. Konno and H. Yamazaki, that the optimal solutions with the absolute deviation model and with the mean-variance model have the same typical behavior, is verified using replica analysis and the belief propagation algorithm.


Portfolio optimization is one of the most fundamental frameworks of risk diversification management. Its theory was introduced by Markowitz in 1959 and is one of the most important areas being actively investigated in financial engineering [13]. In their theoretical research, Ciliberti and Mézard assessed the typical behavior of optimal solutions to portfolio optimization problems, in particular those described by the absolute deviation and expected shortfall models, using replica analysis, one of the most powerful approaches in disordered systems. With this approach, they showed that the phase transitions of these optimal solutions were nontrivial [1]. However, they did not develop an effective algorithm for finding the optimal portfolio with respect to a fixed return set. This requires a rapid algorithm for resolving the optimal portfolio problem with respect to a large enough in-sample set.

As a first step in such a research direction, we propose an algorithm based on belief propagation, which is well-known as one of the most prominent algorithms in probabilistic inference, to resolve the microscopic averages of the optimal solution in a feasible amount of time for a fixed return set. We also confirm whether the numerical experimental results of our novel algorithm are consistent with the ones of replica analysis. Furthermore, the conjecture of Konno and Yamazaki, that if the return at each period is independently and identically drawn from the normal probability distribution [2], the optimal portfolio of the mean-variance model is consistent with that of the absolute deviation model, is supported using replica analysis and belief propagation.

Model Setting and Proposed Algorithm

Let us define the model setting for our discussion. A portfolio of N assets and the return at period μ are represented by w = {w1,w2, ⋯, wN}TRN and xμ = {x1μ,x2μ, ⋯, x}TRN, respectively, where wk is the position of asset k, and we assume for simplicity that the mean of the return of asset k in period μ, x, is zero. The notation T indicates matrix transposition. Given a return set for p periods as reference, the problem is to minimize the following cost function (i.e., Hamiltonian) for the portfolio: (1) where R(u) represents a cost function, such as in the mean-variance model and ∣u∣ in the absolute deviation model, respectively. Furthermore, since the budget is assumed to be finite, the following global constraint is set: (2)

One of our aims is to develop an effective general algorithm for solving this problem; in particular, our aim is an algorithm that works for all cost functions R(u) and all probability distributions of the returns.

As a basis for the proposed algorithm, following examples in statistical mechanics, we set the joint probability of portfolio w used in Eq (1) using finite inverse absolute temperature β as follows: (3) where g(u) = eβR(u) is the likelihood function and prior probability for sufficiently large N [4, 5]. Notice that the partition function of this posterior probability (4) is implicitly ignored in this analysis because intuitively it is possible to evaluate the first- and second-order moments of portfolio wk approximately without the partition function by the following procedure. An arbitrary test probability of portfolio is defined as follows: (5) where the reducibility condition on beliefs bk(wk) and bμ(w), (6) must hold and w\wk denotes a subset of w from which wk is excluded. The Kullback-Liebler divergence (KLD) (7) provides a useful guideline for deriving the belief propagation algorithm. However, since it is too complicated to directly assess KLD except in specific graphical models, we here approximate the Bethe free energy denoted as follows: (8) where is used. The purpose of this step is to derive the optimal portfolio using the beliefs bk(wk) and bμ(w) that minimize the Bethe free energy under the reducibility condition of Eq (6). By adding the term to the right-hand side of Eq (8), it is possible to minimize the Bethe free energy with respect to the beliefs to obtain (9) (10)

Furthermore, for simplicity, we set (11) as novel auxiliary functions, and then bk(wk) and bμ(w) can be rewritten using and as (12) (13)

Moreover, applying the cumulant generating functions (14) (15) the first and second moments of wk have the compact forms and at θ = {θ1, ⋯, θN}T → 0. This allows us to disregard the calculation of the partition function. Then, our proposed algorithm for sufficiently large N comprises the following: (16) (17) (18) (19) (20) (21) (22) (23) where is used. Note that if is redefined as , then and [47]. In addition, and describe the Onsager reaction terms in the literature of spin glass theory (respectively [8, 9]).

Four points should be noticed here. First, the calculation of this procedure is reduced from O(N3) to O(N2). For instance, in the case of the mean-variance model, although we are required to calculate the inverse matrix of the correlation matrix of return set XXT ∈ ℳN×N, where return matrix X = {x1, ⋯, xp} ∈ ℳN×p, in order to assess the optimal solution rigorously, it is well-known that this calculation is O(N3). Moreover, fortunately it is found that in the case of the mean-variance model, this algorithm derives the exact optimal solution (see appendix A for details). Second, only Eqs (20) and (23) are dependent on the likelihood function g(u) = eβR(u), and the variables of index u are the only model dependent ones. Furthermore, is determined by Eqs (2) and (16). Third, the randomness of return is not assumed to be sampled from specific distributions. Because it is plausible that the assumption on the Bethe free energy approximation works correctly if the return at each period is asymptotically not correlated with other returns. Lastly, we expect that in the limit as β → ∞, the estimate of the portfolio of asset k, mwk, asymptotically corresponds to the optimal portfolio with respect to the given return set.

Numerical Experimental Results

In order to confirm the effectiveness of our method, the numerical experimental results of the proposed algorithm and those of the replica analysis for the case of the Markowitz model are shown in Figs 1 and 2, where x are independently and identically drawn from the normal distribution with mean and variance 0 and 1, respectively. The numerical experimental result of belief propagation is assessed from 102 samples of the number of assets N = 500 and is denoted by error bars and the result of replica analysis is denoted by a solid line. Both findings indicate that the two approaches are consistent with each other.

Fig 1. The reference ratio α = p/N (horizontal axis) versus the quenched overlap parameter q (vertical axis).

The numerical experimental results from the proposed algorithm (error bars) are assessed from 102 experiments using N = 500 assets. Comparing with the results of replica analysis (solid line), the effectiveness of proposed algorithm is verified.

Fig 2. The reference ratio α (horizontal axis) versus one degree of the cost functionε (vertical axis).

This result also indicates that the approximation approach based on probabilistic inference works correctly.

With regard to the conjecture of Konno and Yamazaki, the variables in Eqs (20) and (23), in the case of the mean-variance model (24) (25) and the absolute deviation model (26) (27) are assessed exactly using . Because in the case of u ≫ 1, and are estimated; that is, this finding indicates that the conjecture of Konno and Yamazaki is valid in part in the sense of the belief propagation approach. See appendices for details.


In conclusion, we have discussed an effective algorithm for finding the optimal solution of the portfolio optimization problem with respect to an arbitrary cost function according to Ciliberti and Mézard [1]. With loss of generality, applying the likelihood function g(u) defined by the cost function R(u) dependent on the risk diversification problem, we proposed a novel approximation derivation method based on one of the most powerful estimation methods in probabilistic inference. In addition, since two types of Onsager reaction terms are derived in Eqs (17) and (21), our algorithm provides the Thouless, Anderson, and Palmer approach rather than the mean-field approximation in the literature of spin glass theory. One advantage of our algorithm is that it rapidly converges by excluding the effect of self-response. In order to confirm the effectiveness of the proposed approach, we have described the case of the mean-variance model. Furthermore, we have shown that the conjecture of Konno and Yamazaki is supported by employing both approaches developed in cross-disciplinary research involving statistical mechanics and information sciences. In future work, we will assess the properties of R(u) and the randomness of return that make solving the portfolio optimization problem using belief propagation possible.


A. Proof of Exactness

We here confirm the exactness of the proposed belief propagation algorithm for the case of the Markowitz model. Our discussion is restricted to α > 1 for simplicity. From Eqs (21), (24), and (25), we obtain , where mu = {mu1, ⋯, mup}TRp and mw = {mw1, ⋯, mwN}TRN. Furthermore, follows immediately from Eqs (16), (17), and (19), where e = {1, ⋯, 1}TRN. Thus, substituting into the constraint N = eT mw gives the exact optimal solution .

B. Replica Analysis

According to Ciliberti and Mézard, replica symmetry solution of the portfolio optimization problem, where x is independently and identically distributed with N(0,1), is derived as the following extremum: (28) where is the partition function and the notation [⋯]q denotes the quenched average over the return set. Moreover, the quenched overlap parameters become if a = b and q otherwise by employing replica indices a,b = 1, 2, ⋯, n and the assumption of replica symmetry. Furthermore, for large N and p, α = p/NO(1) remains finite and plays an important role as a control parameter with respect to phase transition phenomena. If , then and χ = (β(α − 1))−1 can be exactly calculated in the case α > 1 and q → ∞, and χ → ∞ otherwise. This analytical finding is also verified in by the following. It is well known that the eigenvalue distribution of the correlation matrix in the limit of N → ∞ is asymptotically close to the Marčhenko-Pastur law with and [u]+ = max{u, 0} [10]. Therefore, and one degree of the cost function are obtained straightforwardly using . Applying Marčhencko-Pastur law, that and if α > 1 and approach infinity otherwise follows directly. This is consistent with the findings of replica analysis [5].

In general, the order parameters are derived as follows: (29) (30) (31) (32)

From Eqs (29) and (30), (33) is obtained. In the limit of sufficiently large β of g(u) = eβu, if we assess and asymptotically, then the conjecture of Konno and Yamazaki is confirmed as correct in the sense of replica analysis.

C. The Conjecture of Konno and Yamazaki

This conjecture is related to the assessment of an annealed system in the context of spin glass theory. If the return at period μ, xμ, is independently and identically drawn from N (0, Σ), where Σ ∈ ℳN×N is variance-covariance matrix and w is fixed, the novel variable is distributed as N (0, s2(w)) with . With respect to fixed w, employing one degree of the cost function of the annealed optimization problem , which becomes in the case of the mean-variance model and in the absolute deviation model. This implies that the optimal portfolios of the annealed situations of the two models are consistent with each other. Note that one degree of the cost function in the case of the annealed portfolio problem with the expected shortfall model, with γ > 0 can also be assessed. If , then this optimal solution is identical to those of the previous mentioned models. This finding, that is, , is one part of the contributions reported by Konno and Yamazaki.

However, they optimistically assumed wMV = wAD with respect to a given return set X without any mathematical proof, using (34) (35)

As explained above, with respect to the annealed optimization problem strictly holds; however, wMV = wAD is not always satisfied. For example, in the simple case of N = p = 2 for the two returns x1 = {a, c}T and x2 = {b, d}T, their assumption wMV = wAD does not hold, except under specific special situations.

Although this is apparently contradictory to these obtained findings from both approaches, it is necessary to recognize that the relation wMV = wAD with a fixed return set is equivalent to the sufficient condition qMV = qAD, where and are quenched averages of overlap parameters. Moreover, although wMV = wAD does not hold in general, it is expected that the inner product is approximately 1 because in the case of sufficiently large N.

Supporting Information

S1 Data. Figure 1 and figure 2 from S1 Data.

S1 Data is the result from numerical experiment of S1 File and S2 File.


S1 File. S1 File is main program of C language.


S2 File. S2 File is sub program of C language.



We thank I. Kaku, T. Mizuno and Y. Shimazaki for their fruitful comments.

Author Contributions

Conceived and designed the experiments: TS. Performed the experiments: TS. Analyzed the data: TS. Contributed reagents/materials/analysis tools: TS MY. Wrote the paper: TS MY.


  1. 1. Ciliberti S., Mézard M., 2007. Risk minimization through portfolio replication, The European Physical Journal B., 57(2), 175–180.
  2. 2. Konno H., Yamazaki H., 1991. Mean-absolute deviation portfolio optimization model and its applications to Tokyo stock, Management Science, 37(5), 519–531.
  3. 3. Markowitz H., 1959. Portfolio selection: Efficient diversification of investments, J. Wiley and Sons, New York.
  4. 4. Kabashima Y., 2005. Replicated Bethe free energy: A variational principle behind survey propagation, Journal of the Physical Society of Japan, 74(8), 2133–2136.
  5. 5. Shinzato T., 2015. Self-Averaging Property of Minimal Investment Risk of Mean-Variance Model, PLOS ONE.
  6. 6. Çakmak B., Winther O., Fleury H. B., 2014. S-AMP: Approximate message passing for general matrix ensembles, IEEE, Information Theory Worksop, 192–196.
  7. 7. Minka, T. P., 2001. Expectation propagation for approximate Bayesian inference, Proceedings of the Seventeenth conference on Uncertainty in artificial intelligence, 362–369.
  8. 8. Opper M., Winther O., 2001. Tractable approximations for probabilistic models: The adaptive Thouless-Anderson-Palmer mean field approach, Physical Review Letters, 86(17), 3695. pmid:11329302
  9. 9. Opper M., Winther O., 2001. Adaptive and self-averaging Thouless-Anderson-Palmer mean-field theory for probabilistic modeling, Physical Review E, 64(5), 056131.
  10. 10. Shinzato T., Kabashima Y., 2008. Perceptron capacity revisited: Classification ability for correlated patterns, Journal of Physics A, 41(32), 324013.