We develop a three-parameter H, G1, G2 magnitude phase function for asteroids starting from the current two-parameter H, G phase function. We describe stochastic optimization of the basis functions of the magnitude phase function based on a carefully chosen set of asteroid photometric observations covering the principal types of phase dependencies. We then illustrate the magnitude phase function with a chosen set of observations. It is shown that the H, G1, G2 phase function systematically improves fits to the existing data and considerably so, warranting the utilization of three parameters instead of two. With the help of the linear three-parameter phase function, we derive a nonlinear two-parameter H, G12 phase function, and demonstrate its applicability in predicting phase dependencies based on small numbers of observations.