Measure a certain computational base like |0> or |1>?

Simple qubit state: 1/5*[3, 4i]
measurement against |0> should result in 0.36 against |1> → 0.64

import Yao

reg = Yao.ArrayReg([3.0, 4.0im])  # a unnormalized  state 
Yao.normalize!(reg)
shots = 10000
m=Yao.measure(Yao.ComputationalBasis(), reg; nshots=shots)
global s=0
for i in 1:shots
    global s = s + m[i].buf
end
s/shots

result: 0.6306 → this is OK for measurement against |1>
Where is the result for |0>?

I know a simple question but I stuck with it!

The way you interpreting the measurement result is not correct.

julia> m=Yao.measure(Yao.ComputationalBasis(), reg; nshots=shots)
10000-element Vector{DitStr{2, 1, Int64}}:
 1 ₍₂₎
 0 ₍₂₎
 1 ₍₂₎
 1 ₍₂₎
 1 ₍₂₎
 1 ₍₂₎
 1 ₍₂₎
 0 ₍₂₎
     ⋮
 0 ₍₂₎
 1 ₍₂₎
 0 ₍₂₎
 0 ₍₂₎
 1 ₍₂₎
 1 ₍₂₎
 0 ₍₂₎
 1 ₍₂₎

All the items with 0 ₍₂₎ are the result for |0>. buf is the integer representation of bit strings. For example, with two qubits you will have

julia> reg = ghz_state(2)
ArrayReg{2, ComplexF64, Array...}
    active qubits: 2/2
    nlevel: 2

julia> m=Yao.measure(Yao.ComputationalBasis(), reg; nshots=shots)
10000-element Vector{DitStr{2, 2, Int64}}:
 00 ₍₂₎
 00 ₍₂₎
 11 ₍₂₎
 11 ₍₂₎
 11 ₍₂₎
 11 ₍₂₎
 00 ₍₂₎
 00 ₍₂₎
      ⋮
 00 ₍₂₎
 11 ₍₂₎
 11 ₍₂₎
1 Like

Thank you for my changing the view to the result