What is the endianness of returned bitstrings from `sample`?

I want to generate statevectors from the underlying measured bitstrings. What order are the bitstring arrays returned as? That is, is [1, 0, 0, 0] = '1000' or '0001'?

Hey @cuhrazatee!

The following circuit provides PennyLane code to check:

import pennylane as qml
from pennylane import numpy as np

n_wires = 4
dev = qml.device("default.qubit", wires=n_wires, shots=10)

@qml.qnode(dev)
def samples(bitstring):
    qml.BasisState(bitstring, wires=range(n_wires))
    return [qml.sample(qml.PauliZ(i)) for i in range(n_wires)]

b = [1, 1, 0, 0]

You can see that evaluating this circuit gives:

>>> samples(b).T
array([[-1, -1,  1,  1],
       [-1, -1,  1,  1],
       [-1, -1,  1,  1],
       [-1, -1,  1,  1],
       [-1, -1,  1,  1],
       [-1, -1,  1,  1],
       [-1, -1,  1,  1],
       [-1, -1,  1,  1],
       [-1, -1,  1,  1],
       [-1, -1,  1,  1]])

The output samples have values 1 and -1. The 1 corresponds to the +1 eigenstate of the Pauli matrix \sigma_{z}, which is |0\rangle. The -1 corresponds to the -1 eigenstate of \sigma_{z}, which is |1\rangle. In other words, in the above -1 maps to |1\rangle and 1 maps to |0\rangle.

Hence, we see that for qubit i corresponds to the i-th column of samples(b).T.