gigi
gigi

Reputation: 17

How to fix negative values in log?

So, I am getting the data from a txt file and I want to get specific data within the whole set. In the code, I am trying to grab it by specifying which indexes and which frequencies are being used for those indexes. But my log is showing a negative value and I don't how to fix that. Code is below, thanks!

 indexes = [9,10,11,12,13]
 frequenciesmh = [151,610,1400,4860,18000]
 frequenciesgh = [i*10**-3 for i in frequenciesmh]
 bigclusterallfluxes = bigcluster[indexes]
 bigclusterlogflux151mhandredshift = [i[indexes] for i in bigcluster]

 shiftedlogflux151mh = 
 [np.interp(np.log10((151*10**-3)*i[0]),np.log10(frequenciesgh),i[1:])
                       for i in bigclusterlogflux151mhandredshift]
  shiftflux151mh = [10**i for i in shiftedlogflux151mh]

   bigclusterflux151mhandredshift = 
   np.array(list(zip(shiftflux151mh,np.transpose(bigcluster)[9])))

Upvotes: 0

Views: 2643

Answers (2)

E.Serra
E.Serra

Reputation: 1574

I don't know what you are trying to fix exactly, but I would definitely NOT change the negative values as they would change the power to being positive always (if you know some maths you will understand that that means 1/16 ==> 16 and also 16 ==> 16).

What you probably want, as you are working with frequencies (Which are always between 0 and 1, if you normalize them, to do this divide each of them by the sum of all of them, hence your logarithm will always be smaller or equal to 0) is to make them all positive and have the - log 10 of your probability, which is quite a common value to have, then 1 == 1/10, 2 == 1/100, etc (which in genetics at least are called phred values I believe).

Summarizing always call the minus log, not the log

-math.log(0.0001) 

Upvotes: 1

handras
handras

Reputation: 1628

The abs() function is what you are looking for.

Upvotes: 0

Related Questions