handout

Machine Learning for Language Technology 2015
http://stp.lingfil.uu.se/~santinim/ml/2015/ml4lt_2015.htm
Math Review: Logarithms & Exponentiation
Marina Santini
[email protected]
Department of Linguistics and Philology
Uppsala University, Uppsala, Sweden
Autumn 2015
Acknowledgements
• Wikipedia
• Math is fun; other math websites
Math Review
2
Logarithm: a simple definition
• A logarithm is the power (exponent) to which
a number must be raised in order to get some
other number.
• A logarithm answers the question:
• How many of one number do we multiply to
get another number?
Math Review
3
What’s a logarithm?
Question: How many 2s do we multiply to get 8?
Answer: 2 × 2 × 2 = 8
we needed to multiply 3 of the 2s to get 8
So the logarithm is 3
log2(8) = 3
• the base: the number we are multiplying (a "2" in the
example above)
• how many times to use it in a multiplication (3 times,
which is the logarithm)
• The number we want to get (an "8")
Math Review
4
These things are the same!
Math Review
5
Examples
Example: What is log5(625) ... ?
We are asking "how many 5s need to be multiplied
together to get 625?"
5 × 5 × 5 × 5 = 625, so we need 4 of the 5s
Answer: log5(625) = 4
Example: What is log2(64) ... ?
We are asking "how many 2s need to be multiplied
together to get 64?"
2 × 2 × 2 × 2 × 2 × 2 = 64, so we need 6 of the 2s
Answer: log2(64) = 6
Math Review
6
Exponantiation
• The exponent says how many times to use
the number in a multiplication.
• In this example: 23 = 2 × 2 × 2 = 8
• (2 is used 3 times in a multiplication to get 8)
Math Review
7
Logarithms and exponents are related!
• The logarithm tells us what the exponent is!
Math Review
8
Common LogarithmBase 10
• Sometimes a logarithm is written without a
base, like this:
• log(100)
• This usually means that the base is really 10.
• Example: log(1000) = log10(1000) = 3
Math Review
9
Natural logarithm base e
• Another base that is often used is e (Euler’s
number) which is about 2.71828.
• Example: ln(7.389) = loge(7.389) ≈ 2
• Because 2.718282 ≈ 7.389
Math Review
10
Logarithms can have decimals
• logarithms can have decimal values like 2.5, or
6.081, etc.
• Example: what is log10(26) ... ?
Math Review
11
The logarithm of a fraction/decimal is
negative
• .... Because we devide instead of multiplying
(multiplication and division belong to the same
pattern)
Math Review
12
Quizzes
1.
2.
3.
4.
What is log4(256)?
What is log5(0.0016)?
Write log4(0.0625) = -2 in exponential form
Write 1,024 = 210 in logarithmic form
Math Review
13
Important to remember!
• Entropy is commonly measured in the units of "bits" (per symbol)
because it uses a logarithm of base 2.
• Entropy is also commonly computed using the natural logarithm
(base e, where e is Euler's number), which produces a
measurement of entropy in "nats" per symbol and sometimes
simplifies the analysis by avoiding the need to include extra
constants in the formulas.
• Other bases are also possible, but less commonly used. For
example, a logarithm of base 8 will produce a measurement in
bytes per symbol, and a logarithm of base 10 will produce a
measurement in decimal digits (or hartleys) per symbol. (Wikipedia)
Math Review
14
The end
Math Review
15