Skip to main content
GameDev.net gamedev.net
🔒 Locked

Undoing Powers

Started by mozie Dec 6, 2007 at 11:01 AM 5 replies 1.1k views
Original Post
mozie
mozie
I have been searching google all morning trying to find an answer to my problem. All of the example solutions are too different from my problem, and trying to apply them to my problem results in numbers that are not what I expected. I'm not very experienced at complex math, so I figured I would come ask the smartest community I can think of. :) First of all my goal is to determine the (Elo) rating of the opposing team, given the change in points (only assuming that you won at this point), and your teams current score. I will first show how I calculate how many points are gained from a win (given that we know both ratings). mR (my rating) = 1532 tR (their rating) = 1400 We first calculate the chance to win: Chance = 1 / ( 1 _plus_ (10^((tR-mR)/400))) = 0.681321835 Points = 32 * ( 1 - Chance ) = 10 (rounded down) So given the points gained (10), and my own rating before gaining the points (1532), I want to calculate the other teams rating. Determine chance by points: Chance = 1 - ( Points / 32 ) = 0.6875 Now that we have the chance, we need to solve for tR in the previous expression. I broke it down like this: x = (1 / Chance) - 1 = 0.454 ~= 10^((tR-mR)/400) (I know that I am not getting an exact result because there is a range of ratings that will result in the same point gain, I'm just trying to get a close approximation) My problem is I dont know how to convert the result of x to 10^y when y=-0.33. (tR-mR)/400 = -0.33 = y x = 10^y Once I can solve for y, then the remainder is simply: tR = (y * 400) _plus_ mR What stumps me is how to take x (0.4545) and 'undo' the 10^y to solve for y. None of the sites seem to explain how the operation will apply to a negative-decimal-exponent. They always talk about whole numbers (or fractions, which I tried to use my exponent as a fraction 45/100 but still didn't produce the results I expected), and none of them seem to explain how to undo a power to a negative exponent. I have come to the point where it looks like I might need to use a logarithmic function, but I do not understand them at all at this point. The sites I have been visiting all show how to use the function, and refer to Logarithmic Rules. However I cannot find an explanation on what they represent. I figured I would ask for help before I (possibly) get too off track, seeing as how I really don't understand how to accomplish what I need. Thanks in advance for any input you might have! ps. I couldn't find why its eating my plus sign, thats why I wrote them out as _plus_. Oh well.
TheAdmiral
TheAdmiral
Gage64's derivation is correct, but it should be noted that the log being used is log10 (as opposed to the commonly used loge and log2). If you're using C or C++, then a simple:

y = log10(x);

will sort you out.
Ring3 Circus - Diary of a programmer, journal of a hacker.
mozie
mozie
Awesome!

It looks like log(x)*log(10) = -0.33

Perfect!

Now I just need to do some research on understanding log().

Thanks Gage64.

TheAdmiral-

So it looks like I can just use the Log10() function to reduce the code (using C# for this one, so its Math.Log10() it seems for me). Thanks!

Gage64
Gage64
Quote:

Original post by the TheAdmiral
it should be noted that the log being used is log10 (as opposed to the commonly used loge and log2).


Yeah, we were taught in school that when you leave out the base then it is interpreted as base 10, which is why I didn't mention it. I guess that's not a universal convention?
TheAdmiral
TheAdmiral
Quote:
Original post by Gage64
Yeah, we were taught in school that when you leave out the base then it is interpreted as base 10, which is why I didn't mention it. I guess that's not a universal convention?

I suppose that's a pretty safe assumption in general, especially if you're in the company of engineers. But considering that mathematicians love natural log, computer-scientists love log2 and that we're on the mathematics forum of a computing site, nothing's safe [wink].
Ring3 Circus - Diary of a programmer, journal of a hacker.
Vorpy
Vorpy
mozie, the logarithm functions are simply the inverses of the exponential functions, by definition. If y = kx, then x = logky.

The k in logk is called the base, and it is read "log base k of y".

In programming, log10 is the usual name of the base 10 logarithm function, and log or ln is base e. ln is the usual mathematical notation for the base e logarithm, which is also called the natural logarithm (which explains the abbreviation ln). This is because it appears naturally in mathematics.

If you need to calculate the logarithm with some arbitrary base k, you can use log10(x)/log10(k) or log(x)/log(k). All of the logarithm functions only differ by a constant factor, and both of those formulas in the previous sentence are equivalent to the log base k of x.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.