# -*- coding: utf-8 -*- import numpy as np # Biblioteca para manipulação numérica def metodo_exclusao(N=1): """ Gera um vetor de N elementos """ # Exemplo para f(x) = 2 * x em [0, 1] xmin = 0 xmax = 1 ymax = 2 f = lambda x : 2 * x i = 0 x = np.zeros(N) while i < N: x_cand = xmin + (xmax - xmin) * np.random.rand() y_test = ymax * np.random.rand() if y_test <= f(x_cand): x[i] = x_cand i += 1 return x