qiskit-documentation/docs/api/qiskit/0.40/qiskit.primitives.BaseEstim...

136 lines
3.9 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: BaseEstimator
description: API reference for qiskit.primitives.BaseEstimator
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.primitives.BaseEstimator
---
# BaseEstimator
<Class id="qiskit.primitives.BaseEstimator" isDedicatedPage={true} github="https://github.com/qiskit/qiskit/tree/stable/0.23/qiskit/primitives/base/base_estimator.py" signature="BaseEstimator(circuits: Iterable[QuantumCircuit] | QuantumCircuit | None = None, observables: Iterable[SparsePauliOp] | SparsePauliOp | None = None, parameters: Iterable[Iterable[Parameter]] | None = None, **kwargs)" modifiers="class">
Bases: `qiskit.primitives.base.base_primitive.BasePrimitive`
Estimator base class.
Base class for Estimator that estimates expectation values of quantum circuits and observables.
Creating an instance of an Estimator, or using one in a `with` context opens a session that holds resources until the instance is `close()` ed or the context is exited.
**Parameters**
* **circuits** Quantum circuits that represent quantum states.
* **observables** Observables.
* **parameters** Parameters of quantum circuits, specifying the order in which values will be bound. Defaults to `[circ.parameters for circ in circuits]` The indexing is such that `parameters[i, j]` is the j-th formal parameter of `circuits[i]`.
* **options** Default options.
**Raises**
**ValueError** For mismatch of circuits and parameters list.
## Methods
### close
<Function id="qiskit.primitives.BaseEstimator.close" signature="BaseEstimator.close()">
Close the session and free resources
</Function>
### run
<Function id="qiskit.primitives.BaseEstimator.run" signature="BaseEstimator.run(circuits, observables, parameter_values=None, **run_options)">
Run the job of the estimation of expectation value(s).
`circuits`, `observables`, and `parameter_values` should have the same length. The i-th element of the result is the expectation of observable
```python
obs = observables[i]
```
for the state prepared by
```python
circ = circuits[i]
```
with bound parameters
```python
values = parameter_values[i].
```
**Parameters**
* **circuits** one or more circuit objects.
* **observables** one or more observable objects. Several formats are allowed; importantly, `str` should follow the string representation format for [`Pauli`](qiskit.quantum_info.Pauli "qiskit.quantum_info.Pauli") objects.
* **parameter\_values** concrete parameters to be bound.
* **run\_options** runtime options used for circuit execution.
**Returns**
The job object of EstimatorResult.
**Raises**
* **TypeError** Invalid argument type given.
* **ValueError** Invalid argument values given.
</Function>
### set\_options
<Function id="qiskit.primitives.BaseEstimator.set_options" signature="BaseEstimator.set_options(**fields)">
Set options values for the estimator.
**Parameters**
**\*\*fields** The fields to update the options
</Function>
## Attributes
### circuits
<Attribute id="qiskit.primitives.BaseEstimator.circuits">
Quantum circuits that represents quantum states.
**Returns**
The quantum circuits.
</Attribute>
### observables
<Attribute id="qiskit.primitives.BaseEstimator.observables">
Observables to be estimated.
**Returns**
The observables.
</Attribute>
### options
<Attribute id="qiskit.primitives.BaseEstimator.options">
Return options values for the estimator.
**Return type**
[`Options`](qiskit.providers.Options "qiskit.providers.options.Options")
**Returns**
options
</Attribute>
### parameters
<Attribute id="qiskit.primitives.BaseEstimator.parameters">
Parameters of the quantum circuits.
**Returns**
Parameters, where `parameters[i][j]` is the j-th parameter of the i-th circuit.
</Attribute>
</Class>