A Hebbian Learning Rule for Optimal Decision Making