from qiskit.opflow import X, Z, I

H2_op = (-1.052373245772859 * I ^ I) + \
        (0.39793742484318045 * I ^ Z) + \
        (-0.39793742484318045 * Z ^ I) + \
        (-0.01128010425623538 * Z ^ Z) + \
        (0.18093119978423156 * X ^ X)

import numpy as np
from qiskit.opflow import X, Z, I

N = 2
H = 0*X
for i in range(1,N+1):
    a_i = np.random.random_sample()
    for j in range(1,i+1):
        J_ij = np.random.random_sample()
        H += J_ij*Z*Z
    H += a_i*X
    
print(H)

import numpy as np
from qiskit.opflow import X, Z, I

N = 2
a_1 = np.random.random_sample()
a_2 = np.random.random_sample()
J_21 = np.random.random_sample()
H = a_1*(I^X) + a_2*(X^I) + J_21*(Z^Z)

print(H.to_matrix())

