-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clip probabilities in
QuantumState
(#9762)
* Clip probabilities * clip implictly * add reno * add tests * add renormalization * use sum, not norm * ensure round still works * normalizing seems to re-introduce errors * Tighten floating-point tests In cases of rounding and clipping, it's important that the floating-point output is bit-for-bit correct, so the fuzzy tests weren't ideal (some of these were strict, but it was inconsistent). It's better to use `assertEqual` rather than `assertTrue` where possible so we get better errors on failure. --------- Co-authored-by: Jake Lishman <[email protected]> (cherry picked from commit 07ca200)
- Loading branch information
1 parent
aa5cd1b
commit e2bc291
Showing
6 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
releasenotes/notes/clip-quantumstate-probabilities-5c9ce05ffa699a63.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
fixes: | ||
- | | ||
Clip probabilities in the :meth:`.QuantumState.probabilities` and | ||
:meth:`.QuantumState.probabilities_dict` methods to the interval ``[0, 1]``. | ||
This fixes roundoff errors where probabilities could e.g. be larger than 1, leading | ||
to errors in the shot emulation of the :class:`.Sampler`. | ||
Fixed `#9761 <https://github.com/Qiskit/qiskit-terra/issues/9761>`__. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters