Qlbn#
Quantum-like Bayesian networks (Moreira and Wichert, 2014, 2016).
A discrete Bayesian network gives every full configuration \(x\) a classical probability \(P(x)\). The quantum-like network gives it an amplitude \(\sqrt{P(x)}\,e^{i\theta(x)}\). When unobserved (hidden) variables are marginalised, amplitudes rather than probabilities are summed:
with \(\alpha\) normalising over the values \(v\). Interference terms are proportional to the cosine of the phase differences. With two hidden configurations a phase difference of \(\pi/2\) removes them and gives classical inference; with more configurations no choice of phases removes all of them in general, so the classical network is kept as a separate baseline.
BayesNet: discrete network (variables, parents, conditional tables).classical_marginal(): exact classical inference by enumeration.quantum_like_marginal(): quantum-like inference with one phase per hidden configuration.QLBNModel: fittable model whose parameters are the phases.ClassicalBNModel: baseline with no free parameters.
Classes
Discrete Bayesian network. |
|
Fittable quantum-like Bayesian network. |
|
Classical baseline for |
Functions
Classical posterior of one variable by enumeration. |
|
Quantum-like posterior of one variable (amplitudes summed over hidden configurations). |
|
Number of hidden configurations, i.e. of interference phases. |
|
|
- class BayesNet(variables, parents, cpt)[source]#
Bases:
objectDiscrete Bayesian network.
- configurations(names)[source]#
Iterate over all assignments of some variables.
- Parameters:
names (
sequenceofstr) – Variables to enumerate.- Yields:
dict–{name: value}, initertools.product()order.
- class QLBNModel(**params)[source]#
Bases:
ModelFittable quantum-like Bayesian network.
The network is fixed; the parameters are the phases of the hidden configurations.
- Parameters:
theta1 (
float) – Phases \(\theta_1, \dots, \theta_{H-1}\) (\(\theta_0 = 0\)); at most 8 hidden configurations. Usefor_network()to fit only the phases in use.... (
float) – Phases \(\theta_1, \dots, \theta_{H-1}\) (\(\theta_0 = 0\)); at most 8 hidden configurations. Usefor_network()to fit only the phases in use.theta7 (
float) – Phases \(\theta_1, \dots, \theta_{H-1}\) (\(\theta_0 = 0\)); at most 8 hidden configurations. Usefor_network()to fit only the phases in use.net (
BayesNet) – The network (option).query (
str) – Query variable (option).conditions (
dict) –{condition name: evidence dict}(option). The design is a list of condition names.
- class ClassicalBNModel(**params)[source]#
Bases:
ModelClassical baseline for
QLBNModel: the same network without interference.Takes the same options (
net,query,conditions) and has no free parameters.
- classical_marginal(net, query, evidence=None)[source]#
Classical posterior of one variable by enumeration.
- quantum_like_marginal(net, query, evidence=None, phases=None)[source]#
Quantum-like posterior of one variable (amplitudes summed over hidden configurations).
- Parameters:
net (
BayesNet) – The network.query (
str) – Query variable.evidence (
dict, optional) – Observed values.phases (
array_like, optional) – One phase per hidden configuration, initertools.product()order of the hidden variables’ values. Default all zero.
- Returns:
dict–{value: probability}of the query.
Number of hidden configurations, i.e. of interference phases.