Logarithms between 0 and 1 and ratios
2 views (last 30 days)
Show older comments
Juan Gambetta
on 19 Jul 2018
Edited: Dimitris Kalogiros
on 19 Jul 2018
Hello
I have to divide two things. They are really small, so I did log of both of them and then divided. Now, the thing is that without log, the ratio is less than 1, while, with the log, the ratio is larger than 1. I know this is due to the fact that the smallest number returns a smaller log, which when dividing and cancelling signs, becomes larger. How could I avoid the 'inconsistence' between ratios? I mean, I want to have the same result (ratio less or more than 1) independently of how I do it.
Thank you.
1 Comment
Pawel Jastrzebski
on 19 Jul 2018
What is "two things"? What does it mean "really small"? Your whole description is so vague and the description I doubt anyone will be able to catch up with your problem, not to mention coming up with some help. Can you attach some examples of the data you're working on? And the code that you've developed so far that presents the transformation you've described (logging, dividing, cancelling)? This way we can have a look at the problem, not the description of it...
Accepted Answer
Dimitris Kalogiros
on 19 Jul 2018
Edited: Dimitris Kalogiros
on 19 Jul 2018
Hi Juan
Suppose you have to divide two very small numbers x, y. And assume that 0<x<<0 and also 0<y<<0. A mathematical correct method is to exploit the following indentity :
x/y = exp( log( x/y ) ) = exp( log(x) - log(y) )
So, difference of logarithms is a metric of the ratio.
On the other hand, if you want to calculate the ratio, you must use logarithm difference as argunent to exp function.
More Answers (0)
See Also
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!