What is the relation between the quantities in classical Value at Risk (VaR) calculation and the calculation via quantum computers?
To specify this question, I would like to briefly explain my understanding of the classical and the quantum mechanical part. Therefore let us assume the returns of a certain stock in one day for 500 days:
Here
- the first column correpsonds to the date,
- the second column is the corresponding return after one day and
- the third column represents the sorted returns.
In total there are 500 entries (I just showed 11). The corresponding histogram to these returns after one day is represented in following Figure 2.
In the following we always focus on calculating the 1% VaR
Classical Part 1: Historical data
The classical, historical approach to calculate the VaR ist to collect return data, order them, and then just find the position in the sorted list which corresponds to 1%. In the example provided, the VaR is found at position [1%*500=position 5] corresponding to -2.2815.
Classical Part 2: Monte-Carlo simulation
Nowadays, the VaR is mostly calculated via Monte-Carlo method. Therefore one hast to extract the stochastic properties p of the simulation. Based on these properties p one simulates several curves. Ordering the values for all that curves at the 1-day mark and taking the value corresponding to the curve corresponding to the position 1% gives you the VaR.
Quantum Computing:
At qiskit, there is a great introduction for using quantum computing (qc) to calculate the VaR. I would like to clarify, which properties of the calssical approaches introduced above correspond to the quantities in the qc-way. A very brief explanation to calculate the VaR in the qc-way is as follows (Quantum Risk Analysis. Stefan Woerner, Daniel J. Egger. [Woerner2019]):
- Create an operator $|{R}>$ satisfying $$ \mathcal{R}|0>_n=|\Psi>_n=\sum_i^n\sqrt{p_i}|i>_n $$ which mimics the stochastic properties of our portfolio.
- Create an operator $F$ $$ F:|i>_n|{0}>\to |i>_n\left(\sqrt{1-f(i)}|{0}>+\sqrt{f(i)}|1> \right) $$ with a special $f(i)$ which will give you the VaR after applying on the wave function $|\Psi>_n$ described above.
These are the ingredients to calculate VaR.
Question: Does the $|{R}>$ corresponds to the Histogram represented in Figure 1? So can we just create $|{R}>$ by mimicing the historical sorted returns? So with the returns provided this would mean the qubit $|i>$ corresponds to the histogram from Figure 1 like
$$ |0>\to 1; |1>\to 7; |2>\to 8; |3>\to 21; . . . $$ where 1, 7, 8, 21, ... correspond to the hight of the first, second, third, fourth, ... bar in the histogram?
In this case the Histogram from Figure 1 should correspond to the following Figure from the qiskit-tutorial:




Attempt to answer your questions as briefly as possible. I will restrict to what I see in the arXiv 2018 paper by Woerner and Egger:
$|\psi\rangle_n=\sum_{i=0}^{N-1}\sqrt{p_i}\,|i\rangle_n$ is a state of a register of $n$ qubits where the probability to measure the state $|i\rangle_n$ is $p_i\,.$ Note that $N=2^n$ (you have a typo there) so that the $n$ qubits can (just like classical bits) be used to represent numerical values from $0$ to $N-1\,.$ This means that $|\psi\rangle_n$ models in a single register all possible realizations of a random variable $X$ that can take values in $\{0,...,N-1\}$ with probabilities $p_0,...,p_{N-1}\,.$ This $X$ could be the value of a portfolio, or the returns of a stock.
In the histogram you have depicted you made $M=500$ observations of $X\,.$ This histogram has the $N$ values that $X$ can take on the $x$-axis and the corresponding $p_i$-values multiplied by $M=500$ on the $y$-axis. Specifically for the histogram you have depicted: $Mp_0=1,Mp_1=7,Mp_2=8,Mp_3=21$ and so on. This allows to back out the probabilities $p_i$. The index $i$ is just a label for the values $\{0,...,N-1\}$ on the $x$-axis of the histogram.
Hopefully this answers your question. The following is just for the sake of some completeness:
Woerner and Egger now want to calculate the expectation of a function $f:\{0,...,N-1\}\to[0,1]\,.$ Instead of calculating classically $\mathbb E[f(X)]=\sum_{i=0}^{n-1}p_if(i)$ they attach to each $|i\rangle_n$ an ancilla qubit $\sqrt{1-f(i)}|0\rangle+\sqrt{f(i)}|1\rangle$ which leads to the state $$ \sum_{i=0}^{N-1}\sqrt{1-f(i)}\sqrt{p_i}\,|i\rangle_n|0\rangle+\sum_{i=0}^{N-1}\sqrt{f(i)}\sqrt{p_i}\,|i\rangle_n|1\rangle\,. $$ Then they use amplitude estimation to approximating the probability to measure $|1\rangle$ in the last (the ancilla) qubit. This probability is clearly $\sum_{i=1}^{N-1}f(i)p_i$ which is the expectation they are after.
Clearly, the variance of $f(X)$ is just another expectation $\mathbb E[f^2(X)]$ from which we subtract $\mathbb E[f(X)]^2\,.$ Woerner and Egger can even use their method to calculate value at risk and conditional value at risk (I have no doubts but not looked into those details). I have also not looked into the question if those quantum methods are superior to classical computing.