Skip to content

Commit

Permalink
Merge pull request #50 from vm6502q/qrack_simulator
Browse files Browse the repository at this point in the history
Fix potential binomial distribution <0 or >1 edge case
  • Loading branch information
josh146 committed Mar 3, 2019
2 parents 9c98bff + 1001986 commit 35a55a8
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions pennylane_pq/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ def expval(self, expectation, wires, par):

if self.shots != 0 and expectation != 'Identity':
p0 = (expval+1)/2
p0 = max(min(p0, 1), 0)
n0 = np.random.binomial(self.shots, p0)
expval = (n0 - (self.shots-n0)) / self.shots

Expand Down

0 comments on commit 35a55a8

Please sign in to comment.