We changed numGradientSamples from a field to an optional parameter to
maximize().