def random_density_matrix(length, rank=None, method='<STR_LIT>', seed=None):
if method == '<STR_LIT>':<EOL><INDENT>return __random_density_hs(length, rank, seed)<EOL><DEDENT>elif method == '<STR_LIT>':<EOL><INDENT>return __random_density_bures(length, rank, seed)<EOL><DEDENT>else:<EOL><INDENT>raise QiskitError('<STR_LIT>'.format(method))<EOL><DEDENT>
Generate a random density matrix rho.

Args:
    length (int): the length of the density matrix.
    rank (int or None): the rank of the density matrix. The default
        value is full-rank.
    method (string): the method to use.
        'Hilbert-Schmidt': sample rho from the Hilbert-Schmidt metric.
        'Bures': sample rho from the Bures metric.
    seed (int): Optional. To set a random seed.
Returns:
    ndarray: rho (length, length) a density matrix.
Raises:
    QiskitError: if the method is not valid.