#NEWLINE# def multivariateCauchy( mu , sigma , onlyDiagonal = True ) : #NEWLINE# #INDENT# ' Generates a sample according to a given multivariate Cauchy distribution. ' #NEWLINE# if ( not onlyDiagonal ) : #NEWLINE# #INDENT# ( u , s , d ) = svd ( sigma ) #NEWLINE# coeffs = sqrt ( s ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# coeffs = diag ( sigma ) #NEWLINE# #UNINDENT# r = rand ( len ( mu ) ) #NEWLINE# res = ( coeffs * tan ( ( pi * ( r - 0.5 ) ) ) ) #NEWLINE# if ( not onlyDiagonal ) : #NEWLINE# #INDENT# res = dot ( d , dot ( res , res ) ) #NEWLINE# #UNINDENT# return ( res + mu )