1. A computer-implemented method for motion estimation of images to determine an optimal error metric function for the motion estimation of video data, the method comprising: selecting an initial error metric function, wherein the initial error metric function is derived from a first distribution of a plurality of candidate distributions; performing an initial motion estimation using the initial error metric function, wherein the initial motion estimation produces motion prediction errors; computing a histogram of the motion prediction errors for the initial error metric function; selecting a distribution from the plurality of candidate distributions by, (i) determining a scale factor for each of the candidate distributions, and (ii) performing a statistical test for distribution fitting between the histogram of the motion prediction errors and each candidate distribution using the associated scale factor; selecting an error metric function corresponding to the selected distribution; performing a final motion estimation using the selected error metric function; and performing inter-prediction for video coding using the selected error metric function.