Keywords

1 Introduction

Bayesian networks [10] are probabilistic models which, among their numerous use cases, allow to model complex systems of interconnected random events in games of chance and their influence on each other. There are several approaches to generalizing Bayesian probability theory into the quantum realm [7, 8, 10].

Introducing quantum probability into game theory opens up new opportunities for finding optimal strategies in various games of chance. Apart from well known work on representing quantum strategies as unitary gates [9] or applying quantum entanglement to find optimal strategies [2], there is also relatively new approach to apply quantum Bayesian networks for that purpose [5]. This new approach has not yet been fully explored, therefore we focus on methods, algorithms and numerical support for researchers working this topic.

Proper numerical tools are required due to high complexity of computations essential to perform such experiments. In particular, performing Bayesian inference in Acausal networks, a quantum generalization of Bayesian networks, is not yet fully supported among numerical libraries.

In this paper we present AcausalNets.jl - a library providing a high-level functions for Bayesian inference that can be applied to both classical and quantum Bayesian networks. The library takes advantage of the new approach to numerical computing offered by Julia language [1].

Organization of the Paper. The paper is organized as follows: in Sect. 2 we summarize relevant related work which provided basis and inspiration for this paper. In Sect. 3 we describe Bayesian networks and their usage in higher detail. We also briefly delve into the inference algorithms implemented in AcausalNets.jl. In Sect. 4 we provide in brief detail the principles we followed when implementing the library. Section 5 sums up our results when recreating and expanding experiments first conducted and described in [5]. In Sect. 6 we provide a brief overview of our ideas for further improvements and enhancements of AcausalNets.jl.

2 Related Work

Belief Propagation algorithms that we adapt for quantum Bayes networks in AcausalNets.jl library are covered to a fuller extent in [4] and [10]. The adaptation was done using theoretical foundations for generalizing Bayesian probability theory into the quantum realm described in [7, 8]. To our best knowledge, there is no numerical support for quantum version of that algorithm.

Additionally, our work was inspired by BayesNets.jlFootnote 1 - a Julia library designed for high-level operations on classical Bayesian Networks.

In general, there is a huge variety of software related to quantum information implemented in numerous programming languages, most notably QuantumInformation.jl [3] implemented in Julia. The set of functionalities these libraries provide, while wide, is focused mainly on low-level optimized matrix operations. AcausalNets.jl makes use of matrix operations implemented in QuantumInformation.jl in its implementation of Belief Propagation algorithms.

3 Classical and Quantum Bayesian Networks

Bayesian Networks are probabilistic graphical models used for describing systems of random variables and correlations between their probability distributions. Those networks take a form of a directed acyclic graph, where vertices denote the variables and edges - correlations between them. Bayesian network is usually represented using set of multivariate distributions, which accounts for both variables distributions and their correlations. Typical applications of Bayesian networks include: calculating probability of a given variable values configuration or inferring probability distributions of given variables based on known states of other variables in the network. The variable connection types differ depending on their relation is classical or quantum.

Classical Version - Conditional Dependence. In classical version, as in Fig. 1, the variables in a Bayesian Network may be causally dependent on one other, which means their distributions are conditional. If distribution of variable \(V_2\) is conditionally dependent on the distribution of variable \(V_1\), a happens-before relationship between \(V_1\) and \(V_2\) is implied.

Quantum Version - Acausal Relationships. When generalized to the quantum domain, Bayesian networks can also describe acausal relationships between variables, which may be interpreted as a quantum entanglement between them. As opposed to a causal relationship, such a system of variables is not described as one system at two times, but rather as two systems in a single time frame. An example of such a network is shown in Fig. 2.

Fig. 1.
figure 1

Source: [5]

A Bayesian network where there is a dependency of C on A and B (arrows).

Fig. 2.
figure 2

Source: [5]

States of systems A and B are entangled (zigzag line), and there is classic dependence of C on A and B (arrows).

Inference Algorithms. Inference in Bayesian networks - calculating the probability distribution of a subsystem of variables based on already known variables - is an NP-hard problem [6]. However, there are algorithms which successfully approximate such computations with considerably lower computational complexity. AcausalNets.jl provides implementations of two algorithms for performing inference in Bayesian networks: a non-optimal naive algorithm, as well as the Belief Propagation algorithm [4, 10]. Moreover, the second algorithm has been generalized to the quantum domain based on [7].

4 Design of the Library

AcausalNets.jl API has been designed with simplicity of computations regarding discrete quantum probability systems in mind. It allows the user to perform inference in Bayesian Networks described in Sect. 3.

Defining Bayesian Networks. To define a Bayesian network, one must first define systems of random variables which make up the network. Then a graph is built of those variables by inserting them in topological order. This requirement is essential, since Bayesian network is a directed acyclic graph. An example of the code which defines a network is shown in Fig. 3.

Fig. 3.
figure 3

Using AcasualNets.jl API to build a bayesian network analogous to Fig. 1

Performing Inference. Inference can be performed with or without evidence - the known state of some of the random variables in the network. Known states are represented by a system with appropriate variables and their known distribution. Next, function infer(network, variables, evidence, strategy) is used for conducting inference for variables and evidence passed as arguments. By default, naive inference algorithm is used, but it can be changed in library’s Inference module. The example code for Monty Hall game use case [5] is shown in the Fig. 4.

Fig. 4.
figure 4

Using AcasualNets.jl API to perform Bayesian inference.

Usage of the Julia Language. The software benefits strongly from Julia typesystem [1], which allows to implement general operation on Bayesian Networks based on the type of the distributions the network is dealing with. It is possible because of Julia’s type parametrization properties. More specifically, as shown in the Fig. 5, BayesNet type is parametrized with the type of DiscreteSystem, which specifies the math operations to be perform on probability distributions of the variables. For example, in case of DiscreteQuantumSystem such operations are performed in accordance with definitions of quantum conditional operators [8].

Fig. 5.
figure 5

The structure of AcausalNets.jl modules and types.

AcausalNets.jl has been implemented in version 1.0 of Julia language [1]. Source code is publicly available onFootnote 2. The repository also contains more example use casesFootnote 3 in a convenient form of interactive Jupyter NotebooksFootnote 4.

5 Monty Hall Game Example Use Case

As a use case we use results of quantum Monty Hall game from [5] modeled as Bayesian network shown in Fig. 2. We consider a case where there occur quantum effects between the event A - the placement of the prize and B - the initial choice of the player. We choose two example quantum probability distributions. Equation (1) models the situation where A and B are entangled in the way that due to quantum effects the placement of the prize always turns out to be the same as the initial choice of the player.

$$\begin{aligned} \rho _{AB\_same} = \frac{1}{3} (| 00 \rangle + | 11 \rangle + | 22 \rangle )(\langle 00 | + \langle 11 | + \langle 22 |) \end{aligned}$$
(1)

Equation (2) models the situation where A and B are entangled in the way that due to quantum effects placement of the prize always turns out to be different that the initial choice of the player.

$$\begin{aligned} \begin{aligned} \rho _{AB\_diff} = \frac{1}{6} (| 01 \rangle + | 10 \rangle )(\langle 01 | + \langle 10 |) \\ +\frac{1}{6} (| 02 \rangle + | 20 \rangle )(\langle 02 | + \langle 20 |) + \frac{1}{6} (| 12 \rangle + | 21 \rangle )(\langle 12 | + \langle 21 |) \end{aligned} \end{aligned}$$
(2)

Next, we construct linear combination of these two situations for \(\lambda \in (0,1)\):

$$\begin{aligned} \rho _{AB}=\lambda \rho _{AB\_same} + (1 - \lambda ) \rho _{AB\_diff} \end{aligned}$$
(3)

We aim to find how the probability of the player wining the game by staying with his initial choice depends on \(\lambda \). We construct the Bayesian network as on Fig. 2 with an appropriate \(\rho _{AB}\) and perform inference to obtain the probabilities. We show our results in Fig. 6.We find that for \(\lambda = 0.6\), the game is fair.

Fig. 6.
figure 6

Probability of winning the prize, when player does not change the door for the initial state given by \(\rho _{AB} = \lambda \rho _{AB\_same} + (1 - \lambda ) \rho _{AB\_diff}\)

The above results show that using high level API of AcausalNets.jl library gives the same results as direct calculations presented in [5].

6 Conclusions and Future Work

High-level tools enable researchers to better organize, perform and document their experiments, although sometimes for the price of their flexibility. AcausalNets.jl has been created with aim to abstract out tedious calculations, provide a high-level API for quantum Bayesian inference and leverage the numerical potential of Julia language. We have successfully used our library to reproduce the results of experiments on the quantum version of Monty Hall originally presented in [5]. Moreover, through automating a lot of necessary computations, AcausalNets.jl helps experiment with more complex Bayesian networks. In the future we plan to fully implement the quantum version of Belief Propagation algorithm and test its efficiency on bigger networks. This may lead to interesting new research results in quantum information as well as machine learning in the future.