qml.devices.qutrit_mixed.sample_probs¶
- sample_probs(probs, shots, num_wires, is_state_batched, rng)[source]¶
Sample from a probability distribution for a qutrit system.
This function generates samples based on the given probability distribution for a qutrit system with a specified number of wires. It can handle both batched and non-batched probability distributions.
- Parameters
probs (ndarray) – Probability distribution to sample from. For non-batched input, this should be a 1D array of length QUDIT_DIM**num_wires. For batched input, this should be a 2D array where each row is a separate probability distribution.
shots (int) – Number of samples to generate.
num_wires (int) – Number of wires in the qutrit system.
is_state_batched (bool) – Whether the input probabilities are batched.
rng (Optional[Generator]) – Random number generator to use. If None, a new generator will be created.
- Returns
An array of samples. For non-batched input, the shape is (shots, num_wires). For batched input, the shape is (batch_size, shots, num_wires).
- Return type
ndarray
Example
>>> probs = np.array([0.2, 0.3, 0.5]) # For a single-wire qutrit system >>> shots = 1000 >>> num_wires = 1 >>> is_state_batched = False >>> rng = np.random.default_rng(42) >>> samples = sample_probs(probs, shots, num_wires, is_state_batched, rng) >>> samples.shape (1000, 1)