@jit
def sample_without_replacement(n, k, num_trials=None, random_state=None):
 if (n <= 0):
  raise ValueError('n must be greater than 0')
 if (k > n):
  raise ValueError('k must be smaller than or equal to n')
 m = (1 if (num_trials is None) else num_trials)
 random_state = check_random_state(random_state)
 r = random_state.random_sample(size=(m, k))
 result = np.empty((m, k), dtype=int)
 pool = np.empty(n, dtype=int)
 for i in range(m):
  for j in range(n):
   pool[j] = j
  for j in range(k):
   idx = int(np.floor((r[(i, j)] * (n - j))))
   result[(i, j)] = pool[idx]
   pool[idx] = pool[((n - j) - 1)]
 if (num_trials is None):
  return result[0]
 else:
  return result

@ jit def sample_without_replacement ( n , k , num_trials = None , random_state = None ) : if ( n <= 0 ) : raise ValueError ( 'n must be greater than 0' ) if ( k > n ) : raise ValueError ( 'k must be smaller than or equal to n' ) m = ( 1 if ( num_trials is None ) else num_trials ) random_state = check_random_state ( random_state ) r = random_state . random_sample ( size = ( m , k ) ) result = np . empty ( ( m , k ) , dtype = int ) pool = np . empty ( n , dtype = int ) for i in range ( m ) : for j in range ( n ) : pool [ j ] = j for j in range ( k ) : idx = int ( np . floor ( ( r [ ( i , j ) ] * ( n - j ) ) ) ) result [ ( i , j ) ] = pool [ idx ] pool [ idx ] = pool [ ( ( n - j ) - 1 ) ] if ( num_trials is None ) : return result [ 0 ] else : return result
randomly choose k integers without replacement from 0 .