generate_cost_function: Generate a sum of squares cost function for optimization
Description
This is an internal helper function that generates a sum of squares
cost function for any given r* function (e.g. rnorm, rlognorm). The
resulting function is intended to be used by an optim call for fitting
quantiles to distribution parameters.