There is no KDE implementation in core that I know of. You might want to google around as someone else might already have implemented that though in a third party lib.
Otherwise, for this, you indeed need a custom Function.
So you will need to make sure you have the backward formula written down for the the KDE evaluation.
And in that case, yes you sample above is correct.