Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open Microsoft.Quantum.Math as Math;
- /// # Summary
- /// Prepares a qubit in a state representing a classical probability
- /// distribution {p, 1 - p}.
- /// # Description
- /// Given a qubit in the |0⟩, prepares √p |0⟩ + √(1 - p) |1⟩
- /// for a given probability p.
- operation PrepareDistribution(probability : Double, target : Qubit) : Unit
- is Adj {
- let rotationAngle = 2.0 * ArcCos(Sqrt(1.0 - probability));
- Ry(rotationAngle, target);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement