Logarithms between 0 and 1 and ratios

조회 수: 1 (최근 30일)
Juan Gambetta
Juan Gambetta 2018년 7월 19일
편집: Dimitris Kalogiros 2018년 7월 19일
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
Pawel Jastrzebski
Pawel Jastrzebski 2018년 7월 19일
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...

댓글을 달려면 로그인하십시오.

채택된 답변

Dimitris Kalogiros
Dimitris Kalogiros 2018년 7월 19일
편집: Dimitris Kalogiros 2018년 7월 19일
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.
  댓글 수: 1
Juan Gambetta
Juan Gambetta 2018년 7월 19일
편집: Juan Gambetta 2018년 7월 19일
Thank you, the difference of the logs is a great idea. Very elegant.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by