A simple digital option has a payoff function \(\max(0, \mathbf{1}_{S_T>K})=\mathbf{1}_{S_T>K}\)
The payoff looks like:
We first need to find a way to replicate this payoff with a portfolio that gives a continuous function. The idea is to first observe that if we long a call option with strike \(K\) and short one call option at \(K+1\), the payoff this portfolio would be
Under a limiting process, it is easy to see that the payoff of a portfolio like the above but with shorting a call option with a strike \(K+\Delta K\) approximates a digital option; thus,
\[\begin{align} D(K,T) &= \lim_{\Delta K\to 0}\frac{C(K,T) - C(K+\Delta K, T)}{\Delta K}. \end{align}\]
But rearranging the above equation, we find that
\[\begin{align} D(K,T) &=- \lim_{\Delta K\to 0} \frac{C(K+\Delta K, T) - C(K,T)}{\Delta K}\\ &= -\frac{\partial C_{\operatorname{mkt}}(K,T)}{\partial K} \end{align}\]
Now, how do we compute this derivative? Recall that \[C_{\operatorname{mkt}}(K,T) = C_{\operatorname{BS}}(r,c,S,K,T,{\color{red}{\sigma(K,T)}}),\] where \(\sigma(K,T)\) is the implied probability, so that
\[\begin{align} D(K,T) &= - \frac{\partial C_{\operatorname{BS}}(K,T)}{\partial K} - \frac{\partial C_{\operatorname{BS}}(K,T)}{\partial \sigma} \frac{\partial\sigma(K,T)}{\partial K}\\ & = - \frac{\partial C_{\operatorname{BS}}}{\partial K} - \nu \cdot \operatorname{skew}, \end{align}\]
by the chain rule, and where \(\nu\) is vega and \(\partial\sigma/\partial K\) is the skew obtained from the implied volatility surface. The skew can also be approximated from the slice of the volatility surface:
\[\begin{align} \frac{\partial\sigma(K,T)}{\partial K} \approx \frac{\sigma(K+\Delta K, T)-\sigma(K,T)}{\Delta K} \end{align}\]