BRAGA

02 Writing02-02 Notes02-02-404

Interval Probability

Published 16 Apr 20264 min read
Contents
  1. 01Deep Breakdown
  2. 02Flowchart
  3. 03Real-world use
  4. 04The formula, piece by piece
  5. 05The formula in words
  6. 06Critical Concepts
  7. 07Step-by-step calculation (tiny example)
  8. 08Code examples
P(a≤X≤b)=F(b)−F(a)=∫abf(x)dxP(a \le X \le b) = F(b) - F(a) = \int_a^b f(x) dx
(1)

Deep Breakdown

What it tells me (Situation Awareness): For a continuous RV, the probability of falling in an interval [a,b][a, b] is the area under the PDF between aa and bb, equivalently F(b)−F(a)F(b) - F(a) using the CDF. This is how all continuous probability queries are answered — individual points have zero probability, so intervals are the meaningful unit.

Flowchart

Query: P(a ≤ X ≤b)Method 1:integrate PDFfrom a to bMethod 2: F(b) -F(a) (faster, useCDF lookup)P(a≤X≤b) = areaunder PDFcurveNote: P(X=x) = 0for any singlepoint x

Real-world use

Where it is used

Computing probability that a metric falls in a target range: P(CTR∈[0.03,0.08])P(\text{CTR} \in [0.03, 0.08]), P(delivery time≤5 days)P(\text{delivery time} \leq 5 \text{ days}), $P(\text{revenue per user} > \$50)$, or confidence interval calculations.

Problem it solves

Continuous RVs assign zero probability to single points. Intervals are the only way to compute non-trivial probabilities for continuous variables.

How it solves the problem

Uses the Fundamental Theorem of Calculus: ∫abf(x)dx=F(b)−F(a)\int_a^b f(x)dx = F(b) - F(a), converting an integration problem to a CDF subtraction.

Example in a business

Session duration target range: P(3≤duration≤10 min)P(3 \leq \text{duration} \leq 10 \text{ min}) from a fitted lognormal. Measures what fraction of users achieve "engaged" session length.

The formula, piece by piece

P(a≤X≤b)=F(b)−F(a)=∫abf(x) dxP(a \leq X \leq b) = F(b) - F(a) = \int_a^b f(x) \, dx

  • aa, bb: lower and upper bounds of the interval.
  • F(b)−F(a)F(b) - F(a): CDF subtraction (faster computation).
  • Equivalent to: area under PDF from aa to bb.

The formula in words

"The probability of X falling in [a, b] is the area under the PDF between a and b, or equivalently, CDF(b) minus CDF(a)."

Critical Concepts

  • P(X=c)=0P(X = c) = 0 for any single value cc in a continuous distribution.
  • Inclusion doesn't matter: P(a≤X≤b)=P(a<X<b)=P(a<X≤b)P(a \leq X \leq b) = P(a < X < b) = P(a < X \leq b).
  • Tail probabilities: P(X>a)=1−F(a)P(X > a) = 1 - F(a), P(X<b)=F(b)P(X < b) = F(b).

Step-by-step calculation (tiny example)

Step 1: Standard normal, query P(-1 ≤ Z ≤ 1)

Step 2: CDF subtraction P(−1≤Z≤1)=Φ(1)−Φ(−1)=0.8413−0.1587=0.6827P(-1 \leq Z \leq 1) = \Phi(1) - \Phi(-1) = 0.8413 - 0.1587 = 0.6827

Step 3: Interpret ~68.3% of standard normal mass lies within 1 standard deviation of the mean (the "68-95-99.7" rule).

Code examples

Beginner example (Python)

python
from scipy.stats import norm, lognorm
import numpy as np

# P(-1 ≤ Z ≤ 1) for standard normal
p_1sigma = norm.cdf(1) - norm.cdf(-1)
print(f"P(-1 ≤ Z ≤ 1) = {p_1sigma:.4f}")  # 0.6827

# P(3 ≤ session ≤ 10) for lognormal(s=0.8, scale=exp(1.5))
lognorm_dist = lognorm(s=0.8, scale=np.exp(1.5))
p_engaged = lognorm_dist.cdf(10) - lognorm_dist.cdf(3)
print(f"P(3 ≤ session ≤ 10 min) = {p_engaged:.4f}")

Beginner example (R)

r
p_1sigma <- pnorm(1) - pnorm(-1)
cat(sprintf("P(-1 ≤ Z ≤ 1) = %.4f\n", p_1sigma))  # 0.6827

# Lognormal session duration
p_engaged <- plnorm(10, meanlog=1.5, sdlog=0.8) - plnorm(3, meanlog=1.5, sdlog=0.8)
cat(sprintf("P(3 ≤ session ≤ 10 min) = %.4f\n", p_engaged))

Professional example (Python)

python
import numpy as np
from scipy.stats import lognorm
from dataclasses import dataclass


@dataclass
class EngagementThresholds:
    """Business-defined engagement tiers for session duration."""
    bounce_max: float = 1.0
    low_max: float = 3.0
    engaged_max: float = 10.0
    power_max: float = float("inf")


def session_engagement_distribution(
    meanlog: float, sdlog: float, thresholds: EngagementThresholds | None = None
) -> dict[str, float]:
    """Compute session tier probabilities from a lognormal model.

    Args:
        meanlog: Lognormal mean parameter (log-scale).
        sdlog: Lognormal std parameter (log-scale).
        thresholds: Business-defined tier boundaries in minutes.

    Returns:
        Dict with probability for each engagement tier.
    """
    if thresholds is None:
        thresholds = EngagementThresholds()
    dist = lognorm(s=sdlog, scale=np.exp(meanlog))
    boundaries = [0, thresholds.bounce_max, thresholds.low_max, thresholds.engaged_max, np.inf]
    tier_names = ["bounce", "low", "engaged", "power_user"]
    return {
        name: float(dist.cdf(upper) - dist.cdf(lower))
        for name, lower, upper in zip(tier_names, boundaries[:-1], boundaries[1:])
    }


# Session analytics
result = session_engagement_distribution(meanlog=1.5, sdlog=0.8)
print("Session engagement tier distribution:")
for tier, prob in result.items():
    bar = "#" * int(prob * 40)
    print(f" {tier:<15}: {prob:.4f} ({prob*100:.1f}%) {bar}")

Source: domain knowledge

#probability-statistics#statistical-operations-and-random-variables#continuous-random-variables-crvs

Keyboard shortcuts

Single keys, ignored while typing in a field or with Cmd, Ctrl or Alt held.

0
Home
1 2 3 4
Work, Writing, Tools, About
j / k
Next / previous section on this page
n / p
Next / previous project or essay
u
Up one level
l
Deutsch
t
Light or dark theme
?
This list
Esc
Close