ffsim.random.random_fermion_operator¶
- ffsim.random.random_fermion_operator(norb, *, n_terms=None, max_term_length=None, num_and_spin_conserving=False, seed=None)[source]¶
Sample a random fermion operator.
The terms are sampled independently and uniformly: the length of a term is uniform in
[1, max_term_length], and each of its actions is a creation or annihilation operator, a spin, and an orbital, each chosen uniformly. Ifnum_and_spin_conservingis set to True, then a term is instead built from a uniform number of excitations, each of which pairs a creation with an annihilation operator acting on the same spin. Coefficients are standard complex Gaussians. Because repeated terms are combined, the sampled operator may have fewer thann_termsterms.- Parameters:
norb (
int) – The number of spatial orbitals.n_terms (
int|None) – The number of terms to include in the operator. If not specified,norbis used.max_term_length (
int|None) – The maximum length of a term. If not specified,2 * norbis used.num_and_spin_conserving (
bool) – Whether to sample an operator that conserves particle number and the z component of spin.seed – A seed to initialize the pseudorandom number generator. Should be a valid input to
np.random.default_rng.
- Return type:
- Returns:
The sampled fermion operator.