A dozen? 12 or 13

I’m almost positive this question has been answered by Cecil before, but I couldn’t find it in my two Straight Dope books.

Why is a bakers dozen 13?

I was told that it’s a dozen of today’s doughnuts and one of yesterday’s.

One out of the batch for the baker to eat.

I always heard it was to ensure that at least 12 of the items were ok to eat. Just a WAG though.