SHARE
TWEET

Untitled

a guest Jun 16th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top