memoize the values for continuous variables so we don't calculate gains for values we've alread seen before (hopefully brining a performance improvement)