https://gist.github.com/limitedmage/945473 Python Quantum Computing simulator, Juliana Pena, 2011. Two qubits and superdense coding protocol example. Errata: TwoQubit measure(): zerozeroprob = abs(self.zerozero) ** 2 zerooneprob = abs(self.zeroone) ** 2 onezeroprob = abs(self.onezero) ** 2 should be: zerozeroprob = abs(self.zerozero) ** 2 zerooneprob = abs(self.zeroone) ** 2 + zerozeroprob # cumulative distribution onezeroprob = abs(self.onezero) ** 2 + zerooneprob