Skip to content

How to get accurate expectation value of a circuit with conditional gates #52

Closed
@royess

Description

@royess

I found that conditional_gate now is designed to work in a probabilistic way. I think a batched evaluation can work. But I want to know if there is a way to get the accurate expectation value, which is averaged over conditional measurement outcomes.

An example:

c = tc.Circuit(nqubits)
c.h(0)
z = c.cond_measure(0)
c.conditional_gate(z, [tc.gates.i(), tc.gates.x()], 2)
print(c.expectation_ps(z=[2]))

Now it gives -1 and +1 each with a 0.5 possibilities. But I want to get 0 as an expectation instead. And I suppose in principle this is implementable in the tensor contraction manner.

And this is also related to #46 , where the expectation value of circuits with conditional gates is needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions