View on GitHub
Open this notebook in GitHub to run it yourself
Introduction
In this tutorial, we implement a Quantum Monte Carlo Integration (QMCI) circuit to estimate . The approach samples lattice points on a discretized grid and uses Quantum Amplitude Estimation (QAE) to estimate the fraction of points that lie inside a quarter circle. This fraction directly determines the value of . Following Ref.~[1], lattice-based uniform sampling is appropriate for the present -estimation problem because the task reduces to estimating the fraction of marked grid points. In this setting, QAE estimates the corresponding amplitude with a quadratic speedup over classical Monte Carlo methods. This should be distinguished from classical grid-based quadrature, whose cost generally scales exponentially with the dimension. In contrast, the QAE-based QMCI approach can avoid this curse of dimensionality at the level of amplitude estimation. In more general QMCI applications, such as finance, the practical advantage further depends on whether the required probability distribution and oracle can be implemented efficiently.Method
The goal of this tutorial is to estimate from the area ratio between a square and an inscribed quarter circle. We sample lattice points on a discretized square and determine whether each point lies inside the quarter circle. If the fraction of points inside the quarter circle is denoted by , then and therefore Two -qubit registers are used to represent the - and -coordinates, respectively: Thus, the computational basis corresponds to lattice points in a square of side length . We define the indicator function With uniform sampling, the target quantity is the expectation value This is the probability that a uniformly sampled lattice point lies inside the quarter circle. To estimate this quantity on a quantum computer, we prepare the uniform superposition over all lattice points using so that Then an oracle marks whether each point is inside the quarter circle by writing the value of into an ancilla qubit: Thus, Therefore, the probability of measuring the ancilla qubit in the state is exactly . By applying Quantum Amplitude Estimation (QAE), we estimate this amplitude more efficiently than by classical Monte Carlo integration, and finally compute Compared with classical grid-based quadrature, whose cost grows exponentially with the dimension, this QAE-based approach avoids the curse of dimensionality. Compared with classical Monte Carlo integration, QAE provides a quadratic speedup in the estimation error. In this -estimation task, lattice-based uniform sampling is appropriate because the problem reduces to estimating the fraction of marked grid points. In more general QMCI applications, such as finance, the advantage additionally depends on whether the required probability distribution and oracle can be implemented efficiently.Dataset
We first generate the grid data. is the parameter for number of data.
Simulation: Classical Simulation
Below, as a point of comparison, we first present an example of a classical simulation based on uniformly spaced sampling points.Output:
Quantum Simulation
Option 1: QAE based QMCI
Output:
Output:
Output:
Option2: Iterative QAE based QMCI
Output:
Output:
IAQE Parameters
For the numerical test, we use the standard Classiq IAQE routine. The two main parameters are the target accuracy and the failure probability . We set Here, specifies the target additive accuracy of the amplitude estimation, while specifies the allowed failure probability. Thus, corresponds to a confidence level. This setting is suitable for an initial validation because it keeps the estimation cost moderate while still requiring a reliable confidence level. Once the implementation is verified, can be reduced for a higher-precision estimation.Output:
Output:
Experiment
In this experiment, we examine whether the estimated value approaches the exact solution as the number of qubits increases. Because a larger number of qubits allows exponentially more sampling points to be represented, the discretization becomes finer, and the estimate is expected to become more accurate. By tracking this trend, we can directly evaluate how increasing the qubit number improves the precision of the estimation.Output:

Discussion
How much computational advantage can be achieved? According to Ref. [2], the query complexity of QMCI is given by By contrast, in the classical grid-based calculation considered here, all lattice points are evaluated explicitly. Hence, the computational cost is The table below shows a theoretical comparison of the required number of evaluations and queries.| Item | Classical Grid-Based Integration | Quantum Monte Carlo Integration (IQAE) |
|---|---|---|