Beispiel #1
0
    def generate_samples(self):
        """Generates samples from the qpu.

        Note that the order of the samples returned here is not indicative of the order in which
        the experiments were done, but is instead controlled by a random shuffle (and hence
        set by numpy random seed).
        """
        number_of_states = 2**self.num_wires
        counts = np.rint(self.prob * self.shots,
                         out=np.zeros(number_of_states, dtype=int),
                         casting="unsafe")
        samples = np.repeat(np.arange(number_of_states), counts)
        np.random.shuffle(samples)
        return QubitDevice.states_to_binary(samples, self.num_wires)
Beispiel #2
0
 def generate_samples(self):
     """Generates samples by random sampling with the probabilities returned by the simulator."""
     number_of_states = 2**self.num_wires
     samples = self.sample_basis_states(number_of_states, self.prob)
     return QubitDevice.states_to_binary(samples, self.num_wires)