Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. open Microsoft.Quantum.Math as Math;
  2.  
  3. /// # Summary
  4. /// Prepares a qubit in a state representing a classical probability
  5. /// distribution {p, 1 - p}.
  6. /// # Description
  7. /// Given a qubit in the |0⟩, prepares √p |0⟩ + √(1 - p) |1⟩
  8. /// for a given probability p.
  9. operation PrepareDistribution(probability : Double, target : Qubit) : Unit
  10. is Adj {
  11. let rotationAngle = 2.0 * ArcCos(Sqrt(1.0 - probability));
  12. Ry(rotationAngle, target);
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement