Skip to content

waterflow80/qunatum-computing-log-normal-distribition

Repository files navigation

Quantum Computing - Log Normal Distribution

The Log Normal Distribution is often used to model the price dynamics of assets, particularly in financial applications such as option pricing. To model the log-normal distribution on a quantum computer, we need to “load” the distribution onto a quantum state. This means encoding the probabilities of different outcomes of the asset price into quantum amplitudes.

There is already an implementation of quantum state preparation of the log-normal distribution using 1 qubit, 2 qubits, and 3 qubits [1].

The goal of this project is to extend the existing implementation to prepare a quantum state using 4 qubits. And also, write a generalized algorithm that can be used to prepare a quantum state using any number of qubits.

Qubits Representation

Single Qubit Representation

To produce the mentioned distribution using a single qubit in a quantum circuit, we use RY gates, where RY gates correspond to the following matrix:

Screenshot from 2024-11-10 20-26-59

where 𝜃 is set to:

Screenshot from 2024-11-10 20-27-32

The resulting state will be:

Screenshot from 2024-11-10 20-28-38

The corresponding quantum circuit is:

Screenshot from 2024-11-11 12-31-48

After calculating the qunatum state, we obtain:

Screenshot from 2024-11-10 20-28-38

The probability distribution will be:

Screenshot from 2024-11-11 12-46-37

Two Qubits Repersentation

To prepare the distribution using two qubits, we must split the coefficient P0 of |0> and assign the split values too |00> and |01> with the ratio P00:P01. Then we split the coefficient P1 of |1> and assign those values to |10> and |11> with the ratio P10:P11. We can achieve this state using two additional RY gates with the two angles:

|Screenshot from 2024-11-10 20-52-14 | Screenshot from 2024-11-10 20-52-22 |

The corresponding quantum circuit is:

Screenshot from 2024-11-11 12-37-26

After calculating the qunatum state, we obtain: Screenshot from 2024-11-10 21-03-29

The probability distribution will be:

Screenshot from 2024-11-11 12-40-49

Three Qubits Representation

We can use the same logic to prepare a quantum state with three qubits. The new required rotation angles will be:

|Screenshot from 2024-11-10 21-55-16 | Screenshot from 2024-11-10 21-55-23 | Screenshot from 2024-11-10 21-55-31 | Screenshot from 2024-11-10 21-55-38 |

The resulting circuit will be:

Screenshot from 2024-11-11 13-05-11

The probability distribution will be:

Screenshot from 2024-11-11 13-07-00

Four Qubit Representation

For the four-qubit representation, we were able to identify a pattern of the order of the application of RY gates, and created an algorithm that produces the quantum circuit for any given number of qubits. The new angles for the RY gates will be:

| theta7 | theta8 | theta9 | theta10 | | theta11 | theta12 | theta13 | theta14 |

The corresponding quantum circuit will be:

4-qubit-circuit

And we will eventually get the fowllowing distribution:

4-qubit-distrot

Challenges

Using the approach described in this report to prepare a quantum state that represents a log normal distribution might be very resource consuming. And, as we increase the number of qubits, the number of gates also increases exponentially. The following graph show the increase of the number of gates in function of the number of qubits used:

increase

Run

In order to run the project, you should follow the following steps:

# clone the project locally
git clone https://github.com/waterflow80/qunatum-computing-log-normal-distribition.git
# locate in the root directory
cd qunatum-computing-log-normal-distribition
# create a python virtual environment 
python3.8 -m venv venv
. venv/bin/activate
# install dependencies
venv/bin/pip install -t requirements.txt
# run the notebook using vscode or spyder (in order to visualize the plots)
code .
# set the virtualenv in vscode to be venv
# execute the cell

To change the number of qubits, set the N_QUBITS = X in the top of the script to your desired X.

References

[1] https://medium.com/qiskit/systematic-preparation-of-arbitrary-probability-distribution-with-a-quantum-computer-165dfd8fbd7d

About

Prepare a qunatum cirtuit that represent a log normal distribution

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published