In [8]:
from statistics import mean, stdev
def atipico(muestra):
media = mean(muestra)
desviacion = stdev(muestra)
def f(n):
puntuacion = (n - media) / desviacion
return (puntuacion < -3) or (puntuacion > 3)
return f
def datos_atipicos(muestra):
return list(filter(atipico(muestra), muestra))
print(datos_atipicos([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1000]))