I'm looking for an efficient way to extract from an array in Python only significant values, for instance, only those 10 times bigger than the rest. The logic (no code) using a very simple case is something like that:
array = [5000, 400, 40, 10, 1, 35] # here the significant value will be 5000.
from i=0 to len.array # to run the procedure in all the array components
delta = array[i] / array [i+1] # to confirm that array[i] is significant or not.
if delta >= 10 : # assuming a rule of 10X significance i.e significance = 10 times bigger than the rest of elements in the array.
new_array = array[i] # Insert to new_array the significant value
elif delta <= 0.1 : # in this case the second element is the significant.
new_array = array[i+1] # Insert to new_array the significant value
at the end new_array will be composed by the significant values, in this case new_array =[5000], but must apply to any kind of array.
Thanks for your help!
UPDATE!!!
Thanks to all for your answers!!! in particular to Copperfield who gave me a good idea about how to do it. Here is the code that's working for the purpose!
array_o = [5000,4500,400, 4, 1, 30, 2000]
array = sorted(array_o)
new_array = []
max_array = max(array)
new_array.append(max_array)
array.remove(max_array)
for i in range(0,len(array)):
delta = max_array / array[i]
if delta <= 10:
new_array.append(array[i])