on the face of it if it s "simply" mathematics then you just write the equation as a function (set of functions)

and add it your select statement...

you need to translate the math/method into something that a non mathematican.statistian cann understand...