# What are the odds

We sometimes hear the expressions:

• “What are the odds?”,
• “The odds of that happening…”.

So what are odds?

Probability concerns an activity that is known as a trial or an experiment. This is just a name for something that has a total number of possible outcomes.

We are interested in the likelihood that an event, which is one or more outcomes, will occur.

With a die (singular for dice), we have 6 total possible outcomes (one, two, three, four, five or six). An event can be a just a single outcome – say throwing a five, or a number of outcomes such as throwing an even number (either a two, four or six).

Probability is expressed as a fraction

$\frac{event \> outcomes}{total \> number \> of \> possible \> outcomes}$

Probability as a fraction, takes values from 0 to 1. Where 0 means “will never occur”, and 1 means ” will definitely occur”.

With our die, the probability for the event of throwing a five is:

$\frac{1}{6}$

There are 6 total possible outcomes (one, two, three, four, five or six), and the event of throwing a five, has just one outcome (five).

## Odds

Odds also express the likelihood of an event occurring, but do it in a slightly different way, that can be more convenient in assessing the likelihood that an event will occur.

With odds, we express the event outcomes:

• Not to the total number of outcomes, as with regular probability,
• But only to the number of outcomes not in the event.

With odds, there are two forms,

• Odds for (aka “in favor”, or “on“)
• Odds against (aka “unfavorable“)

## Odds “for”, or “in favor”

$\frac{number \> of \> event \> outcomes}{number \> of \> outcomes \> not \> in \> the \> event}$

For our example of throwing a five, we have

$\frac{1}{5}$

This is usually written in one of these ways:

• 1 to 5
• 1:5
• 1:5 for
• 1:5 on

Odds can be easier in trying to understand the likelihood of an event occurring.

## Odds “against” or “unfavorable”

The odds against, just reverses the odds for.

$\frac{number \> of \> outcomes \> not \> in \> the \> event}{number \> of \> event \> outcomes}$

Still with our example of throwing a five, we have

$\frac{5}{1}$

This is usually written in one of these ways:

• 5 to 1
• 5:1
• 5:1 against

# Napier’s magic logarithms

We take calculating for granted these days. Use a computer with a spreadsheet, or a programming language …… and the numbers start flying around.

It wasn’t always like this.

## John Napier

Let’s step back to the very early 1600s, John Napier is calculating his logarithm tables in Scotland, United Kingdom. He has spent about 20 years computing them …… not a job for the faint of heart.

In his time like ours, calculating was required for navigation, astronomy and a whole number of activities to support science and technology.

Working by hand (as you really had no option then) – adding and subtracting were not too bad, but multiplication and division could test the abilities of the very best.

## What is a logarithm

Logarithms grow out of powers, also known as exponents.

We can represent numbers, as powers of another number  – called a base.

Here, we take 2 as the base, raise it to power of 3 …… and we have a representation for 8:

$2^3=8$ … which is just … $2\times2\times2=8$

Logarithms are the powers of the base, that represent other numbers. So here 3 is the logarithm of 8 using the base 2.

You can use any number for the base.

## Working with logarithms (aka logs)

The neat thing about logarithms, is that you can do a number of things more easily, including performing:

• Division by simply subtracting.

As the numbers involved get bigger, so does the benefit. This was a huge labor-saving effort in John Napier’s time, and even up until comparatively recently.

In videos of the NASA Apollo moon missions in the 60s and 70s, you can catch glimpses of engineers using slide rules, which are rulers that can do amongst other things, logarithms.

Logarithms have a notation as follows

$number = base^{power}$   …… becomes ……   $\log _{base} number = power$

Lets say we want to multiply 8 by 4, which would result in 32. Using logarithms:

• $8 = 2^3$   …… becomes ……   $\log _2 8 = 3$
• $4 = 2^2$   …… becomes ……   $\log _2 4 = 2$

We now we just add the powers or logarithms 3 and 2, to get 5.

We then reverse the process – which is sometimes called taking the anti-logarithm.

Take the base which is 2 and raise it to the logarithm which is 5, and we get our answer:

$2^5=32$ … which is just $2\times2\times2\times2\times2=32$

## Tables

John Napier, and those who followed created handy tables of these wonder numbers called logarithms.

The creation of these tables was a time-consuming task, and there are numerous approaches. You can start with the consecutive powers or logarithms, here 1, 2 and 3:

• $\log_2 2 = 1$
• $\log_2 4 = 2$
• $\log_2 8 = 3$

Now you can use various techniques to fill in the gaps, such as between $\log_2 2$ and $\log_2 4$, which often are approximations. You can read more about this process here.

## Logs in the wild

Logarithms or logs often appear nature. For instance the Richter scale for earthquakes, is a scale of logarithms to the base 10.

For example, an earthquake that measures 5.0 on the Richter scale has a shaking amplitude 10 times larger than one that measures 4.0.

Shows logs also work for very small numbers …

# Building the Natural numbers, an axiom at a time

Number is a fundamental concept of math and of life. Bones have been found for the stone age with notches in them – used for counting.

There is more than one kind of number. We start from Natural numbers for counting from 0, 1, 2, and on through 3. From these we create numbers that can be less than zero, or a fractional part of a number.

It might surprise you then, that the formal basis for these foundational numbers, only goes back to the later part of the 19th century.

## Enter axioms

The different branches of math like numbers, geometry and trigonometry …… are based on what we consider to be simple assumed facts, which we can just accept. We call these simple assumed facts axioms.

The trick is, that from these axioms, we can continually derive new facts. This is how the branches of math have grown, and continue to grow.

## Axioms of Natural numbers

The axioms of the Natural numbers are known as the Dedekind–Peano axioms, and are described here. Let’s take a quick look at these axioms, and I will try to provide some commentary.

We have to start somewhere, so we assume 0 is a natural number:

• 0 is a natural number.

The axioms then go on to define the equals or equality relation. Relations are used in math to compare things.

Equals relation

• For every natural number x, x = x

So something is equal to itself, e.g. 2 = 2

• For all natural numbers x and y, if x = y, then y = x.

So the order does not matter, say x = my age, which say is 25

Let’s also say y = Alice’s age which is also 25

Then x = y, and y = x

• For all natural numbers x, y and z, if x = y and y = z, then x = z.

We have my age x, and Alice’s age y, but let me tell you that Alice’s age is the same as Diana’s age z.

So we have now y = z, we know x = y …… so we must have x = z

• For all a and b, if a is a natural number and a = b, then b is also a natural number.

This means that every Natural number, has another Natural number it is equal to – the same number. It is not as if say 35 is not equal to anything. The bottom line is that we can use = without worrying it will suddenly stop working and leave us in the lurch.

Successor operation

Operations are the actions of math. The Dedekind–Peano axioms now go on to define a successor operation which we will call S(n), where n is some Natural number.

• For every Natural number n, S(n) is a natural number.

So we are saying that every Natural number has a successor.

S(0) = 1, S(1) = 2, S(2) =  3 ……

But wait, there is a chain to these numbers, we could also say

S(0) = 1, S(S(0)) = 2, S(S(S(0))) = 3 ……

• For every natural number n, S(n) = 0 is false.

So this is just saying there is no Natural number who has a successor of 0. So 0 is the start of the Natural numbers.

• For all natural numbers m and n, if S(m) = S(n), then m = n.

This axiom is telling us that the Natural numbers are ordered. No two different Natural numbers can have the same successor.

• We need to show that the successor operation can produce all the Natural numbers, or put another way, that every Natural number is included in (or is a subset of) – the set of 0 and its successors:

Let’s say K is a set of such that:
If 0 is in K, and
for every natural number n, if n is in K, then its successor S(n) is also in K,
then K contains every natural number.

Using the above, we can define the arithmetic operation of addition.

We define addition recursively, that is if terms of a repeating definition of itself. Let’s say that

• a + 0 = a
• a + S(b)  = S(a+ b)

Now we can define a + 1 as:

a + 1 = a + S(0) = S(a + 0)

S(a + 0) = S(a).

So if a was 5, then we have S(5) = 6

We can continue this and define a + 2 as:

a + 2 = a + S(1)  = S(a + 1)

S(a + 1) = S(a + S(0))  = S(S(a + 0))

S(S(a + 0)) = S(S(a)))

So if a was 5 again, then S(S(5)) = S(6) = 7

## Wrap up

We build the branches of math from axioms.

The Natural numbers are based on axioms know as the Dedekind–Peano axioms.

Axioms provide a foundation to continuously derive the rest of the math facts from. However as you can see, even for something as simple as the Natural numbers, it takes quite a bit of work and it is low-level detail

So for most people, learning math involves just learning the higher level derived math facts, or rules. They can take for granted that these were derived from the axioms by others and not worry about the axioms themselves.

However, I hope now you have seen how math is created in layers, with axioms being the lowest or most fundamental layer.

# Finding yourself got easier

Finding yourself these days has got a lot easier.

## Latitude and longitude

We measure our position in coordinates of latitude and longitude, a system that originated in the middle ages.

• Latitude measures in lines called parallels, how far north or south of the equator a place is located:
• The equator is situated at ,
• The North Pole at 90° north (or 90°, because a positive latitude implies north), and the South Pole at 90° south (or –90°).
• Latitude measurements range from 0° to + or – 90°.
• Longitude measures in lines called meridians, how far east or west of the prime meridian a place is located:
• The prime meridian runs through Greenwich, England (near London).
• Longitude measurements range from 0° to + or – 180°.

# Current location

You can just use a map service, for example with Google Maps:

• The map will usually open at your current location,
• Just right mouse click on the map, and select What’s here?
• The latitude and longitude of that pint are displayed in the search box as described here

# Coordinate format

Latitude and longitude coordinates can be displayed in a number of different ways as described here.

For example, the latitude and longitude of the Basilica of la Sagrada Familia in Barcelona can be expressed as:

• Degrees, minutes and seconds 41° 24′ 12.1674″, 10′ 26.508″
• Degrees and decimal minutes 41 24.2028, 2 10.4418
• Decimal degrees 41.40338, 2.17403 – this is the one most commonly used by Geographic Information Systems.

# Zero gets even

Is zero even?

The possibly surprising answer is yes.

## By the rules

Lets looks at some of the rules from here for evenness:

• even ± even = even
• odd ± odd = even
• even × integer = even

Certain values cause these rules to return a result of zero:

• 2 − 2 = 0
• −3 + 3 = 0
• 4 × 0 = 0

These rules would be broken if zero was not even.

The bit about evenness starts around 1:02

# The keys to keeping a secret

There has been a lot in the news lately about keeping information and especially personal information secret.

Math has and continues to play a critical role in keeping information secret, by encrypting it to prevent people from reading it. Then those we want to, can reverse this process with decryption, to get back the original information.

Keeping secrets with encryption has a long history, going all the way back to Julius Caesar.

### Symmetric key encryption

Encryption and decryption rely on a key, which is used in some kind of math operation to do the hiding.

Up until fairly recently the only game in town was symmetric key encryption. This uses one key for both encryption and decryption.

The problem here, is that you have to get the key to the other party you are sending the encrypted information … without anyone else getting their hands on it.

### Public key encryption

Public key encryption, solves the above “key distribution problem”. It uses two keys, a public key which can be handed out like candy, and a private key which you don’t share with anyone.

When someone wants to send you some encrypted information, they encrypt it with your public key and send it to you. You can then decrypt it with your private key and read the information.

To pull this trick off relies heavily on modular arithmetic.

In modular arithmetic, when we divide by a number, we only keep the remainder. So for example, 12 modular divided by 10 … divides 1 time, and the remainder is 2, so our answer is 2.

• 12 mod 10 = 2

Now we can think about something called modular inverses. These are two whole numbers when multiplied together in modular arithmetic give 1:

• (3 x 7) mod 10
• 10 mod 10
• = 1

If we multiply a number by this, we get the same number as a result:

• 4 x (3 x 7) mod 10
• = 4 x 21 mod 10
• = 84 mode 10 … (divides 8 times, throw that away, keep the remainder 4)
• = 4

Now this is where the trick starts. Let’s say I give out the pair 3 and the 10 as a public key, and keep the 7 to myself as a private key. You then “encrypt” the 4 like this:

• 4 x (3) mod 10
• = 12 mod 10
• = 2

… you send me the 2, which is the encrypted information. I now decrypt with the private key 7 and the original 10:

• 2 x (7) mod 10
• = 14 mod 10
• = 4

Now someone could have figured out that my private key was 7 … but if I use much larger numbers instead of 3,7 and 10 … it becomes extremely  difficult to figure out what my private key is. However it remains fairly easy for me to decrypt with that private key.

So modular arithmetic can offer a lot more than novelty value.

### RSA

The most popular method for public key encryption is RSA, named after the authors Ron Rivest, Adi Shamir and Leonard Adleman, who first publicly described it in 1977.

The RSA wiki page for it here gives the details.

### Example in R

Here is an R programming language snippet of code that uses the PKI (Public Key Infrastructure) package:
• Generate RSA private and public keys
• Encrypt some text
• Decrypt it again
install.packages(“PKI”)
library(“PKI”)
key <- PKI.genRSAkey(2048)
x <- charToRaw(“Hello, world!”)
e <- PKI.encrypt(x, key)
y <- PKI.decrypt(e, key)
stopifnot(identical(x, y))
print(rawToChar(y))

This code is an example form the PKI R package documentation

Khan Academy multiple videos on encryption

# Moment by moment – Kurtosis

In the last three posts we have been talking about moments, which are  measurements that describe some aspect of the shape of a given set of points or values.

We first talked about the first moment mean, then the second moment called the variance. Last week we talked about skewness.

Let’s now conclude this series, with the fourth moment, which is known as the kurtosis.

Kurtosis describes how peaked or flat the distribution of our values are.

## Types of kurtosis

• Values of a  normal distribution with zero kurtosis are called  mesokurtic,
• Values with positive kurtosis are called leptokurtic, with a steeper and thinner peak,
• Values with negative kurtosis are called platykurtic, with less of a peak and being flatter.

## R code

I struggled to come up with some R code to generate the values for the above plots having leptokurtic and platykurtic kurtosis – but here’s what I came up with.

I used R’s random exponential distributed values function (rexp) to generate each side of the slope. I then overlaid used varying amounts of R’s random uniform distributed values function, to shape the centers. There are 3 separate programs here, and they should be run individually:

### 1. Mesokurtic

# mesokurtic (Normal)
library(e1071)
library(VGAM)

values <- rnorm(10000, mean=5, sd=50)

# Plot the histogram of the points
hist(values, breaks=100, main=”mesokurtic (Normal)”, xlab=”math4uandme.com”, freq=FALSE)
curve(dnorm(x, mean=mean(values), sd=sd(values)), add=TRUE, col=”red”, lwd=3)

the.mean = mean(values)

# Overlay the mean
abline(v=the.mean, col=”blue”,lwd=3)
kurtosis(values)

### 2. Leptokurtic

# leptokurtic
library(e1071)
library(VGAM)

rate=0.5
values.neg <- 0 – rexp(n=5000, rate=rate)
values.pos <- rexp(n=5000, rate=rate)
values = c(values.neg, values.pos)
values <- values + runif(100, min=-0.2, max=0.2)

# Plot the histogram of the points
hist(values, breaks=100, main=”leptokurtic”, xlab=”math4uandme.com”, freq=FALSE)
curve(dnorm(x, mean=mean(values), sd=sd(values)), add=TRUE, col=”red”, lwd=3)

# Overlay the mean
the.mean = mean(values)
abline(v=the.mean, col=”blue”,lwd=3)
kurtosis(values)

### 3. Platykurtic

# platykurtic
library(e1071)
library(VGAM)

rate=0.5
values.neg <- 0 – rexp(n=5000, rate=rate)
values.pos <- rexp(n=5000, rate=rate)
values = c(values.neg, values.pos)
values <- values + runif(250, min=-20, max=20)

# Plot the histogram of the points
hist(values, breaks=100, main=”platykurtic”, xlab=”math4uandme.com”,freq=FALSE)
curve(dnorm(x, mean=mean(values), sd=sd(values)), add=TRUE, col=”red”, lwd=3)

# Overlay the mean
the.mean = mean(values)
abline(v=the.mean, col=”blue”,lwd=3)
kurtosis(values)