Skip to content

Commit

Permalink
Merge pull request #460 from qiboteam/fixnumpy
Browse files Browse the repository at this point in the history
normalizing probs
  • Loading branch information
scarrazza committed Sep 8, 2021
2 parents 9af4e77 + fc333eb commit 4073ce9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/qibo/backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def __init__(self):
# Create the default active backend
if "QIBO_BACKEND" in os.environ: # pragma: no cover
self.active_backend = os.environ.get("QIBO_BACKEND")
self.active_backend = active_backend
else:
self.active_backend = active_backend

# raise performance warning if qibojit and qibotf are not available
self.show_config()
Expand Down
3 changes: 2 additions & 1 deletion src/qibo/backends/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ def sample_shots(self, probs, nshots):
def sample_frequencies(self, probs, nshots):
from qibo.config import SHOT_BATCH_SIZE
def update_frequencies(nsamples, frequencies):
samples = self.random.choice(range(len(probs)), size=nsamples, p=probs)
samples = self.random.choice(
range(len(probs)), size=nsamples, p=probs/self.backend.sum(probs))
res, counts = self.backend.unique(samples, return_counts=True)
frequencies[res] += counts
return frequencies
Expand Down

0 comments on commit 4073ce9

Please sign in to comment.