liveBook · Manning

Log probability

As explained in Causal AI

A log probability is the natural logarithm of a probability value.

A log probability is the natural logarithm of a probability value. Probability distributions commonly expose log probabilities because they offer computational advantages over ordinary probabilities. Applying the exponential function converts a log probability back to the probability scale. section 2.1.7

Bernoulli probability in Pyro

For a Bernoulli distribution with probability 0.4, log_prob evaluates the outcome 1.0 on the logarithmic scale. Applying math.exp to that result returns approximately 0.4; the small discrepancy comes from floating-point rounding. section 2.1.7

lprob = bern.log_prob(torch.tensor(1.0))

import math
print(math.exp(lprob))

The executable example shows how to obtain a Bernoulli log probability and convert it back to probability with math.exp. section 2.1.7

How Causal AI covers it

How deep it goes
Defines the transformation, explains its computational motivation, and demonstrates conversion back, but does not derive numerical-stability details.
Examples
Demonstrates Pyro's Bernoulli(0.4), log_prob for outcome 1.0, and math.exp reconstruction.
What it assumes
Assumes familiarity with probability values and canonical distributions while introducing logarithmic representation from the definition.
What you can do after
Apply it via Pyro and Python by evaluating log_prob and exponentiating the result.
How it connects
Connects log probability with probability distributions, Bernoulli distribution, conditional probability, and the chain rule.

Also explained in

Compare how 8 books explain log probability →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Causal AI. The section links point to the parts of the book it draws on.