# Dispersion Probability Math Specification

This document specifies the exact club-ranking math executed in both Dispersion for iOS (`Probability.swift`, `Sigma.swift`) and the web Probability Lab (`src/features/dispersion/domain/`).

## 1. Club Dispersion Parameters

Each full-swing club is represented by three numbers:

- `carryYards` ($\mu_{\text{carry}}$): average carry distance
- `carrySd` ($\sigma_{\updownarrow}$): unbiased sample standard deviation of carry distance
- `lateralSd` ($\sigma_{\leftrightarrow}$): unbiased sample standard deviation of lateral miss

Putters are deliberately excluded from this model and live in a separate domain (make-rate brackets and lag-putt proximity).

## 2. Independent 2D Gaussian Band Integration

Given a target at distance $d$, safe zone width $W$, safe zone depth $D$, and lateral aim offset $a$:

$$
\Delta_{\text{carry}} = \mu_{\text{carry}} - d
$$

$$
P_{\text{raw}}(\text{in zone}) =
\left[\Phi\!\left(\frac{+D/2 - \Delta_{\text{carry}}}{\sigma_{\updownarrow}}\right) - \Phi\!\left(\frac{-D/2 - \Delta_{\text{carry}}}{\sigma_{\updownarrow}}\right)\right]
\times
\left[\Phi\!\left(\frac{+W/2 - a}{\sigma_{\leftrightarrow}}\right) - \Phi\!\left(\frac{-W/2 - a}{\sigma_{\leftrightarrow}}\right)\right]
$$

Where $\Phi(z)$ is the standard normal cumulative distribution function computed via the Abramowitz & Stegun 26.2.17 rational approximation (max absolute error $\approx 7.5 \times 10^{-8}$).

## 3. Exponential Short-Side Penalty

Because missing short of greens generally incurs higher expected strokes (bunkers, water, false fronts) than finishing pin-high or slightly long, clubs whose expected carry is shorter than the target receive an exponential penalty:

$$
P_{\text{adjusted}} =
\begin{cases}
P_{\text{raw}} \cdot \exp\!\left(-b \cdot |\Delta_{\text{carry}}|\right) & \text{if } \Delta_{\text{carry}} < 0 \text{ and } b > 0 \\
P_{\text{raw}} & \text{otherwise}
\end{cases}
$$

The default short-side bias coefficient is $b = 0.08$ (tunable in iOS Settings and in the web Probability Lab).

## 4. Sample Calibration Estimator

Given $n \ge 2$ logged shots with longitudinal deltas $y_i$ and lateral deltas $x_i$:

$$
\sigma_{\updownarrow} = \sqrt{\frac{1}{n - 1}\sum_{i=1}^{n}(y_i - \bar{y})^2},
\qquad
\sigma_{\leftrightarrow} = \sqrt{\frac{1}{n - 1}\sum_{i=1}^{n}(x_i - \bar{x})^2}
$$
