forked from microsoft/Quantum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.qs
32 lines (26 loc) · 1.28 KB
/
Program.qs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
namespace Microsoft.Quantum.Samples.PhaseEstimation {
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Intrinsic;
@EntryPoint()
operation RunProgram () : Unit {
// We pick an arbitrary value for the eigenphase to be
// estimated. Note that we have assumed in the Q# operations that
// the prior for the phase φ is supported only on the interval
// [0, 1], so you might get inconsistent answers if you violate
// that constraint. Try it out!
let eigenphase = 0.344;
// We run the PhaseEstimationIteration(). That operation
// checks that the iterative phase estimation step has the right
// likelihood function.
Message("Phase Estimation Likelihood Check:");
PhaseEstimationIterationCheck();
// We run the BayesianPhaseEstiamtionSample operation
// defined in Q#. This operation estimates the phase φ using an
// explicit grid approximation to the Bayesian posterior.
Message("Bayesian Phase Estimation w/ Explicit Grid:");
let est = BayesianPhaseEstimationSample(eigenphase);
Message($"Expected {eigenphase}, estimated {est}.");
}
}