# Blahut–Arimoto algorithm

Suppose we have a source ${\displaystyle X}$ with probability ${\displaystyle p(x)}$ of any given symbol. We wish to find an encoding ${\displaystyle p({\hat {x}}|x)}$ that generates a compressed signal ${\displaystyle {\hat {X}}}$ from the original signal while minimizing the expected distortion ${\displaystyle \langle d(x,{\hat {x}})\rangle }$, where the expectation is taken over the joint probability of ${\displaystyle X}$ and ${\displaystyle {\hat {X}}}$. We can find an encoding that minimizes the rate-distortion functional locally by repeating the following iteration until convergence:
where ${\displaystyle \beta }$ is an inverse temperature parameter that controls how much we favor compression versus distortion (higher ${\displaystyle \beta }$ means less compression). It should be noted that the above algorithm only converges locally to an optimal point on the rate-distortion curve. Finding the global optimum is a computationally hard problem.