def compression_matrix(data, q, n_power_iter=0, seed=None):
 n = data.shape[1]
 comp_level = compression_level(n, q)
 state = RandomState(seed)
 omega = state.standard_normal(size=(n, comp_level), chunks=(data.chunks[1], (comp_level,)))
 mat_h = data.dot(omega)
 for j in range(n_power_iter):
  mat_h = data.dot(data.T.dot(mat_h))
 (q, _) = tsqr(mat_h)
 return q.T

def compression_matrix ( data , q , n_power_iter = 0 , seed = None ) : n = data . shape [ 1 ] comp_level = compression_level ( n , q ) state = RandomState ( seed ) omega = state . standard_normal ( size = ( n , comp_level ) , chunks = ( data . chunks [ 1 ] , ( comp_level , ) ) ) mat_h = data . dot ( omega ) for j in range ( n_power_iter ) : mat_h = data . dot ( data . T . dot ( mat_h ) ) ( q , _ ) = tsqr ( mat_h ) return q . T
randomly sample matrix to find most active subspace this compression matrix returned by this algorithm can be used to compute both the qr decomposition and the singular value decomposition .