Core: states, measurement, fitting and comparison#
Everything else in the library is built from the definitions on this page.
Notation#
Symbol |
Meaning |
|---|---|
\(\psi \in \mathbb{R}^d\) or \(\mathbb{C}^d\), \(\lVert\psi\rVert = 1\) |
belief state (pure) |
\(\rho = \lvert\psi\rangle\langle\psi\rvert\), \(\rho \succeq 0\), \(\operatorname{tr}\rho = 1\) |
density matrix (pure or mixed) |
\(P = P^\dagger = P^2\) |
orthogonal projector of a “yes” answer; \(\bar P = I - P\) is “no” |
\(\theta\) |
vector of model parameters |
\(\mathcal{D} = \{c: n_c\}\) |
data: outcome counts \(n_{c,o}\) per condition \(c\) |
Born rule and Lüders rule#
Answering a yes/no question with projector \(P\) gives
For a sequence of questions \(q_1, \dots, q_m\) with answers \(a_k \in \{0, 1\}\) and projectors \(P_k^{(1)} = P_k\), \(P_k^{(0)} = I - P_k\), applying the rule repeatedly gives
If two projectors do not commute, \(P_B P_A \neq P_A P_B\), the joint probability depends on the order:
this single fact produces question-order effects, conjunction fallacies and interference.
(core.linalg.luders, core.linalg.sequence_probabilities)
The projector onto the span of vectors \(v_1, \dots, v_r\) is \(P = QQ^\dagger\), where the columns of \(Q\) are
an orthonormal basis of the span (QR decomposition). (core.linalg.projector)
Parameterising states and subspaces#
A real unit vector in \(\mathbb{R}^d\) is written with hyperspherical angles,
and an orthonormal frame with \(d(d-1)/2\) Givens rotations \(G_{ij}(\phi_{ij})\) (rotation by \(\phi_{ij}\) in
the \((i, j)\) plane), \(F = \prod_{i<j} G_{ij}(\phi_{ij})\). (angles_to_unit, givens_frame)
Mixed states, dephasing and open-system dynamics#
Partial dephasing in a basis of projectors \(\{P_k\}\) with strength \(s \in [0, 1]\):
The Lindblad (GKSL) equation with Hamiltonian \(H\), jump operators \(L_k\) and rates \(\gamma_k \ge 0\):
The library builds \(\mathcal{L}\) as a \(d^2 \times d^2\) matrix acting on the row-stacked \(\rho\) and uses the
matrix exponential. (lindblad_superoperator, evolve_density)
Parameters and their transforms#
Each parameter has a kind that maps it to an unconstrained value \(z\) used by the optimiser:
Kind |
Range |
Map from \(z\) |
|---|---|---|
|
\((0, 1)\) |
\(p = 1/(1 + e^{-z})\) |
|
\((0, \infty)\) |
\(x = e^{z}\) |
|
\((\ell, h)\) |
\(x = \ell + (h - \ell)/(1 + e^{-z})\) |
|
\(\mathbb{R}\) |
\(x = z\) |
Likelihood#
For multinomial models (counts of outcomes), with predicted probabilities \(p_{c,o}(\theta)\),
(the multinomial coefficients are constant and omitted; probabilities are clipped at \(10^{-12}\)).
For judgement models (observed mean values \(y_c\) against predictions \(\hat y_c(\theta)\)) the loss is the sum of squared errors \(\mathrm{SSE} = \sum_c (y_c - \hat y_c)^2\), and the Gaussian log-likelihood with the variance profiled out is used for comparison,
Fitting and comparison#
\(\hat\theta = \arg\max_\theta \log L(\theta)\) by Nelder-Mead from several random starts (and over all discrete structures, such as projector ranks). Models are ranked by
with \(k\) fitted parameters and \(n\) observations (lower is better). The BIC weight of model \(m\) is
Model recovery. For each generating model \(g\), simulate \(R\) data sets, fit every candidate, and record \(\Pr(\text{selected} = m \mid g)\). A design can tell the models apart when this matrix is close to the identity.
Individual fits. For people \(i = 1, \dots, I\), the group criterion of a model is \(\sum_i \mathrm{BIC}_i\) (each person has their own parameters), compared with the BIC of one pooled fit.
Distances between distributions. \(\mathrm{KL}(p\Vert q) = \sum_i p_i\log(p_i/q_i)\) and \(\mathrm{TVD}(p, q) = \tfrac12\sum_i\lvert p_i - q_i\rvert\).
Reference: Burnham & Anderson (2002); Busemeyer & Bruza (2024), chapters 2-3.
Extensions for every model#
These three tools work with every multinomial model in the library (the bootstrap also with least-squares models). They are what Quantum Mind adds to the published models: the papers report point estimates fitted once to a group, while a robot needs uncertainty, per-person adaptation and a way to choose its next question.
Parametric bootstrap (bootstrap()). From the fit
\(\hat\theta\), simulate \(b = 1, \dots, B\) data sets with the observed totals \(n_c\),
refit each to get \(\hat\theta^{(b)}\), and report the percentile interval \(\bigl[q_{\alpha/2}, q_{1-\alpha/2}\bigr]\) of \(\{\hat\theta^{(b)}\}\) for each parameter and of \(\{p_c(\hat\theta^{(b)})\}\) for each predicted probability.
Online per-person model (OnlinePersonModel). Particles
\(x_i \sim \mathcal N(x_0, \Sigma_0)\) on the unconstrained scale (\(\Sigma_0 = s^2 I\) or a population covariance), \(i = 1, \dots, N\), with \(x_0\) the
population estimate. After outcome \(k\) in condition \(c\),
with \(\bar w\) the normalised weights. When \(\mathrm{ESS} < \tfrac12 N\), the particles are resampled systematically and each is moved by Metropolis-Hastings steps with a Gaussian random-walk proposal \(x' = x_i + \mathcal N\bigl(0, \tfrac{2.38^2}{k} V\bigr)\) (\(V\) the particle covariance, \(k\) the number of parameters), accepted with probability \(\min\{1, \pi(x')/\pi(x_i)\}\) where \(\log\pi(x) = -\tfrac12 (x - x_0)^T \Sigma_0^{-1} (x - x_0) + \sum_c\sum_k y_{c,k}\log p_{c,k}(x)\) is the log posterior given every answer so far. These moves leave the posterior unchanged and restore the diversity that resampling removes (resample-move). Predictions are posterior predictive, \(\hat p_c = \sum_i \bar w_i\, p_c(x_i)\).
Choosing the most informative condition (information_gain()).
For models \(m\) with probabilities \(w_m\), one observation in condition \(c\) carries
the mutual information between the model identity and the outcome (the weighted Jensen-Shannon
divergence; with BIC weights it equals the ensemble disagreement of
HumanModelEnsemble). After observing counts \(y\), the
model probabilities become \(w_m \propto w_m \prod_c \prod_k p_{m,c,k}^{\,y_{c,k}}\)
(model_posterior()).
References: Efron, B., & Tibshirani, R. J. (1993). An Introduction to the Bootstrap. Chapman & Hall. Chopin, N. (2002). A sequential particle filter method for static models. Biometrika, 89(3), 539-551. Myung, J. I., & Pitt, M. A. (2009). Optimal experimental design for model discrimination. Psychological Review, 116(3), 499-518.