Adaptive history biases result from confidence-weighted accumulation of past choices