Phase shifting is a technique for phase retrieval that requires a series of intensity measurements with certain phase steps. The purpose of the present work is threefold: first we present a new method for generating general phase-shifting algorithms with arbitrarily spaced phase steps. Second, we study the conditions for which the phase-retrieval error due to phase-shift miscalibration can be minimized. Third, we study the phase extraction from interferograms with additive random noise, and deduce the conditions to be satisfied for minimizing the phase-retrieval error. Algorithms with unevenly spaced phase steps are discussed under linear phase-shift errors and additive Gaussian noise, and simulations are presented.