intial commit of some legacy matlab code i found for logistic substitution