Given \(n\) data points \(x_1, \dots, x_n\) in \(\mathbb{R}^d\), t-SNE first computes conditional probabilities \(p_{j|i}\) representing the similarity of \(x_j\) to \(x_i\):
\[p_{j|i} = \frac{\exp\!\bigl(-\lVert x_i - x_j \rVert^2 / 2\sigma_i^2\bigr)}
{\sum_{k \neq i} \exp\!\bigl(-\lVert x_i - x_k \rVert^2 / 2\sigma_i^2\bigr)},\]
where \(\sigma_i\) is chosen so that the perplexity of the conditional distribution equals a user-specified target. The symmetrized joint distribution is
\[P_{ij} = \frac{p_{j|i} + p_{i|j}}{2n}.\]
In the low-dimensional embedding \(y_1, \dots, y_n\), pairwise affinities use a Student’s \(t\)-distribution with one degree of freedom:
\[Q_{ij} = \frac{\bigl(1 + \lVert y_i - y_j \rVert^2\bigr)^{-1}}
{\sum_{k \neq l} \bigl(1 + \lVert y_k - y_l \rVert^2\bigr)^{-1}}.\]
The embedding is found by minimizing the Kullback–Leibler divergence:
\[\mathrm{KL}(P \| Q) = \sum_{i \neq j} P_{ij} \log \frac{P_{ij}}{Q_{ij}}.\]