def make_low_rank_matrix(n_samples=100, n_features=100, effective_rank=10, tail_strength=0.5, random_state=None):
 generator = check_random_state(random_state)
 n = min(n_samples, n_features)
 (u, _) = linalg.qr(generator.randn(n_samples, n), mode='economic')
 (v, _) = linalg.qr(generator.randn(n_features, n), mode='economic')
 singular_ind = np.arange(n, dtype=np.float64)
 low_rank = ((1 - tail_strength) * np.exp(((-1.0) * ((singular_ind / effective_rank) ** 2))))
 tail = (tail_strength * np.exp((((-0.1) * singular_ind) / effective_rank)))
 s = (np.identity(n) * (low_rank + tail))
 return np.dot(np.dot(u, s), v.T)

def make_low_rank_matrix ( n_samples = 100 , n_features = 100 , effective_rank = 10 , tail_strength = 0.5 , random_state = None ) : generator = check_random_state ( random_state ) n = min ( n_samples , n_features ) ( u , _ ) = linalg . qr ( generator . randn ( n_samples , n ) , mode = 'economic' ) ( v , _ ) = linalg . qr ( generator . randn ( n_features , n ) , mode = 'economic' ) singular_ind = np . arange ( n , dtype = np . float64 ) low_rank = ( ( 1 - tail_strength ) * np . exp ( ( ( - 1.0 ) * ( ( singular_ind / effective_rank ) ** 2 ) ) ) ) tail = ( tail_strength * np . exp ( ( ( ( - 0.1 ) * singular_ind ) / effective_rank ) ) ) s = ( np . identity ( n ) * ( low_rank + tail ) ) return np . dot ( np . dot ( u , s ) , v . T )
generate a mostly low rank matrix with bell-shaped singular values most of the variance can be explained by a bell-shaped curve of width effective_rank: the low rank part of the singular values profile is:: * exp(-1 .