mindquantum.utils.random_hamiltonian
- mindquantum.utils.random_hamiltonian(n_qubits: int, n_terms: int, seed: int = None, dtype=None)[source]
Generate a random Pauli Hamiltonian.
- Parameters
- Returns
Hamiltonian, Randomly generated Hamiltonian
Examples
>>> ham = random_hamiltonian(4, 5, seed=42) >>> print(ham) -0.5018 [Z0] + 1.8029 [X0 X1] + 0.928 [Y0 X1 Y2] + 0.3946 [Z2 X3] - 1.3759 [Z1 Y3]