I am working with very small p-values (several hundred decimals) and I am trying to detect the smallest one in the list. It seems like Python detects many of them as zero so I get a zero division error when I log.
To avoid this, I have written this code:
smallest_val = min(np.array(p_value)[np.array(p_value) > 0])
for i in range(len(p_value)):
if p_value[i] == 0:
p_value[i] = smallest_val
p_value_log = []
for i in p_value:
b = log(i)
p_value_log.append(b)
Of course, this does not solve my problem as several small p-values are then equal to smallest_val and I can't identify the smallest. Any idea on the best way to go about this?