Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 5

Converting Between Probabilities, Odds, Log-Odds, Exponentials, and Logarithms

Recommended resources

Welcome back. In the previous lesson, rank made exact redundancy in a design matrix visible: when feature columns are linearly dependent, individual linear-model coefficients are not uniquely determined. We now reuse the linear-prediction idea in a different setting: binary outcomes such as whether a B2B SaaS workspace converts within 60 days.

A linear score can take any real value, but a conversion probability must lie between and . This lesson develops the transformations that connect those two worlds: probability, odds, log-odds, exponentials, logarithms, and the sigmoid function. These are foundational for logistic regression, calibration, and later causal-inference work involving propensity scores.


From a probability to odds

Let

denote the probability of an event—for example, the probability that an eligible trial workspace converts to paid.

A probability is bounded:

If the conversion probability is , then the probability of non-conversion is

Odds compare the probability of the event to the probability that it does not occur:

For ,

Thus the odds are , often written as 1 to 4 against conversion: for every one conversion, there are four non-conversions in the corresponding ratio.

Probability and odds are related, but they are not interchangeable.

Probability Interpretation Odds
1% probability , about 1 to 99
20% probability , 1 to 4
50% probability , 1 to 1
80% probability , 4 to 1
90% probability , 9 to 1

The central reference point is:

At a 50% probability, the event and non-event are equally likely. Below 50%, odds are below 1; above 50%, odds are above 1.

To reverse the conversion, begin with odds :

Solving for :

So the two directions are:

For instance, odds of imply

or an 80% probability.

Odds and Log(Odds), Clearly Explained!!!

Watch “Odds and Log(Odds), Clearly Explained!!!” by StatQuest with Josh Starmer for a visual, count-based explanation of why odds are event occurrences relative to non-occurrences, rather than relative to all outcomes.

Watch odds basics first. Focus on the difference between a probability such as 5/8 and odds such as 5/3, and on why calculating from counts or probabilities gives the same odds. Then watch log odds, paying particular attention to the symmetry created by taking logarithms of reciprocal odds.



Why take the logarithm of odds?

Odds are always positive:

That is an improvement over probabilities, but the scale remains asymmetric around the neutral point . For example:

  • odds of mean the event is disfavored;
  • odds of mean the event is favored.

These are reciprocal quantities, but they do not look equally far from on the raw odds scale.

Taking the natural logarithm fixes this. The log-odds, also called the logit, are

The notation means the natural logarithm: logarithm with base , where

The logarithm and exponential functions undo each other:

provided .

Here are the same probabilities on all three scales:

Probability Odds Log-odds

Notice the symmetry:

The neutral probability corresponds to odds of , and therefore to log-odds of zero:

Unlike probability and odds, log-odds can take any real value:

This is why log-odds are useful for a linear model. A weighted sum such as

can be any real number. Logistic regression treats this linear score as log-odds, not as a probability.

A crucial distinction:

The first expression is the log of a probability. The second is the logit, or log-odds. In logistic regression, it is the second quantity that is modeled as linear.



Returning from log-odds to probability: exponentials and the sigmoid

Suppose a model or calculation gives a log-odds value :

Exponentiate both sides:

The left-hand side is now the odds. Solving for gives:

An equivalent and computationally familiar form is:

This function is called the sigmoid or logistic function:

It transforms every finite real number into a number strictly between and :

Calculating a probability with the sigmoid function

Read Google Machine Learning Crash Course’s explanation of the sigmoid function. It connects the algebra you have just seen to the geometric picture of turning an unrestricted linear score into a valid probability.

In the “Sigmoid function” section, read the formula and the input-output table. Use the lookup table to verify the key landmarks z=-1,0,1 and how rapidly the curve approaches its endpoints. Then read the “Transforming linear output using the sigmoid function” subsection and its deeper mathematical explanation of why the linear output is log-odds. Finish with the Figure 2 discussion: the linear transformation example shows the same input values before and after applying the sigmoid.

A linear score \(z=2x+5\) on the left is passed through the sigmoid function on the right. The highlighted scores \(-10\), \(0\), and \(5\) become probabilities near \(0\), exactly \(0.5\), and near \(1\), respectively.

The image shows three especially useful landmarks:

The sigmoid is not “making the relationship linear.” It does the opposite: it turns a linear log-odds score into a nonlinear probability curve. Near , changes in the score can visibly change probability. At very large positive or negative scores, probabilities saturate near or .



Odds ratios: the multiplicative meaning of a log-odds change

Logarithms are useful because they turn multiplication into addition:

Correspondingly, exponentials turn addition back into multiplication:

Suppose log-odds change by some amount :

Exponentiating both sides implies:

Since is odds,

Thus:

is an odds ratio: the factor by which the odds change.

For example, if , then

A increase in log-odds doubles the odds.

However, doubling odds does not mean doubling probability. The resulting probability depends on the starting probability.

Suppose a workspace starts with:

Its odds are:

Doubling odds gives:

Converting back:

So its probability rises from 1% to about 1.98%, not to 2% exactly and certainly not to 100%.

Now start instead at:

The starting odds are:

Doubling those odds gives , which corresponds to:

The same odds ratio of produces a change from 60% to 75%.

This distinction will matter when reading logistic-regression results later:

  • an odds ratio above means higher odds;
  • an odds ratio below means lower odds;
  • it is not a direct percentage-point change in probability;
  • it is also not, by itself, a causal effect.


A compact conversion workflow in Python

For routine work, it helps to calculate all representations together and inspect whether the values make sense.

import numpy as np

p = np.array([0.20, 0.50, 0.80])

odds = p / (1 - p)
log_odds = np.log(odds)

# Invert log-odds with the sigmoid formula
p_recovered = 1 / (1 + np.exp(-log_odds))

for probability, odd, logit, recovered in zip(
    p, odds, log_odds, p_recovered
):
    print(
        f"p={probability:.2f}, "
        f"odds={odd:.3f}, "
        f"log-odds={logit:.3f}, "
        f"recovered p={recovered:.2f}"
    )

The expected output is approximately:

p=0.20, odds=0.250, log-odds=-1.386, recovered p=0.20
p=0.50, odds=1.000, log-odds=0.000, recovered p=0.50
p=0.80, odds=4.000, log-odds=1.386, recovered p=0.80

There is one mathematical boundary condition worth remembering. The logit is undefined at exactly and :

is not finite, and neither is the logit at . In contrast, the sigmoid of any finite is always strictly inside the interval:

This is one reason the sigmoid is well suited to transforming a finite model score into a probability.



Key takeaways

The five transformations in this lesson form one connected system:

The sigmoid maps an unrestricted linear score to a valid probability. A change in log-odds corresponds to a multiplicative change in odds after exponentiation, but the implied probability change depends on the initial probability.

Next, the course moves to the calculus tools behind learning model parameters: the product rule and chain rule.