# integrate_monte_carlo

Source: https://docs.q-ctrl.com/references/fire-opal/fireopal/fireopal.integrate_monte_carlo

```python
fireopal.integrate_monte_carlo(problem, credentials, backend_name=None, integrator_options=None, run_options=None, adaptive=None)
```

Solve a Monte Carlo integration problem.

### Parameters
* **problem** (*dict* *[* *str* *,* *Any* *]*  *|* *dict* *[* *str* *,* *str* *]*) – A dictionary containing a pre-built quantum circuit
  representing the composition of the objective function
  and probability distribution, in the format
  `{"preparation_circuit": <QASM string>}`.
  Alternatively, it is a dictionary containing the objective
  function and probability distribution, built using
  [`make_monte_carlo_problem()`](https://docs.q-ctrl.com/references/fire-opal/fireopal/fireopal.make_monte_carlo_problem.md#fireopal.make_monte_carlo_problem). Objective functions
  can be created with helpers such as
  [`make_european_call_pricing_objective()`](https://docs.q-ctrl.com/references/fire-opal/fireopal/fireopal.make_european_call_pricing_objective.md#fireopal.make_european_call_pricing_objective),
  [`make_european_call_delta_objective()`](https://docs.q-ctrl.com/references/fire-opal/fireopal/fireopal.make_european_call_delta_objective.md#fireopal.make_european_call_delta_objective), or
  [`make_fixed_income_pricing_objective()`](https://docs.q-ctrl.com/references/fire-opal/fireopal/fireopal.make_fixed_income_pricing_objective.md#fireopal.make_fixed_income_pricing_objective),
  and distributions with
  [`make_lognormal_distribution()`](https://docs.q-ctrl.com/references/fire-opal/fireopal/fireopal.make_lognormal_distribution.md#fireopal.make_lognormal_distribution),
  [`make_normal_distribution()`](https://docs.q-ctrl.com/references/fire-opal/fireopal/fireopal.make_normal_distribution.md#fireopal.make_normal_distribution),
  [`make_uniform_distribution()`](https://docs.q-ctrl.com/references/fire-opal/fireopal/fireopal.make_uniform_distribution.md#fireopal.make_uniform_distribution), or
  [`make_gci_model_distribution()`](https://docs.q-ctrl.com/references/fire-opal/fireopal/fireopal.make_gci_model_distribution.md#fireopal.make_gci_model_distribution).
* **credentials** (*Credentials*) – Credentials for the target hardware provider, created using the
  appropriate helper from the [`fireopal.credentials`](https://docs.q-ctrl.com/references/fire-opal/fireopal/fireopal.credentials.md#module-fireopal.credentials) module. For
  example, use [`make_credentials_for_ibm_cloud()`](https://docs.q-ctrl.com/references/fire-opal/fireopal/fireopal.credentials.make_credentials_for_ibm_cloud.md#fireopal.credentials.make_credentials_for_ibm_cloud) for
  IBM backends.
* **backend_name** (*str*) – Name of the target backend device (for example, `"ibm_boston"`). Call
  [`show_supported_devices()`](https://docs.q-ctrl.com/references/fire-opal/fireopal/fireopal.show_supported_devices.md#fireopal.show_supported_devices) to list available names
  for your credentials.
* **integrator_options** (*dict* *[* *str* *,* *Any* *] or* *None* *,* *optional*) – 

    A dictionary containing options for the integrator. Default is None. If None,
    default options will be used. The expected keys in the dictionary are:
    - “max_iteration_count”: int, optional
    > The maximum number of iterations to perform before terminating the
    > integration process. If the value exceeds the maximum recommended
    > value (`MAX_ITERATION_COUNT`), a warning is issued.
    - ”target_variance”: float, optional
      : The target variance for the estimate. The integration process will
        terminate once the variance of the estimate is below this threshold.
    - ”full_output”: bool, optional
      : If True, the integration process will return detailed
        information about each iteration in the `metadata` field
        of the result. Defaults to False.
  * **run_options** (*RunOptions* *or* *None* *,* *optional*) – Provider-specific execution options, for example,
    [`IbmRunOptions`](https://docs.q-ctrl.com/references/fire-opal/fireopal/fireopal.run_options.IbmRunOptions.md#fireopal.run_options.IbmRunOptions).
    See the [`fireopal.run_options`](https://docs.q-ctrl.com/references/fire-opal/fireopal/fireopal.run_options.md#module-fireopal.run_options) module for available classes.
    Defaults to None.
  * **adaptive** (*bool* *or* *None* *,* *optional*) – Whether to use the adaptive integration strategy, which chooses each
    iteration’s circuits from the previous results. The non-adaptive strategy
    determines all circuits up front. Defaults to None, in which case the
    strategy follows the execution mode: adaptive when jobs run in a session,
    and non-adaptive otherwise. Adaptive integration outside a session runs,
    but each iteration waits in the device queue.
### Returns
[`FireOpalJob`](https://docs.q-ctrl.com/references/fire-opal/fireopal/fireopal.FireOpalJob.md#fireopal.FireOpalJob) – A job object whose [`result()`](https://docs.q-ctrl.com/references/fire-opal/fireopal/fireopal.FireOpalJob.result.md#fireopal.FireOpalJob.result) method returns a dictionary
containing:

  `estimate (float)`
  : The estimate of the integral.

  `variance (float)`
  : The variance of the estimate.

  `iteration_count (int)`
  : The number of iterations performed.

  `metadata (dict[str, Any])`
  : Additional information about the integration process. If `full_output`
    is True, `metadata["iterations"]` contains a list of dictionaries,
    each representing an iteration of the integration process, with keys
    `"estimate"`, `"variance"`, and `"iteration_count"`.
### Raises
**QctrlArgumentsValueError** – If `backend_name` is not provided when submitting a circuit, if an
    unsupported objective function or distribution is specified, if both
    a circuit and a named config are provided for the same component, or if
    the IBM `run_options` combine an execution mode and IDs that conflict.
