1. A transform coding apparatus, comprising: an input scale factor calculating section that calculates an input scale factor having a predetermined number of scale factors associated with an input spectrum as an element; a codebook that stores a plurality of scale factor candidates having a predetermined number of elements and outputs one scale factor candidate; an error calculating section that calculates an error on a per element basis by subtracting the scale factor candidate from the input scale factor on a per element basis; a weighted error calculation section, including a processor or integrated circuit, that determines a weight on a per element basis such that a greater weight is applied when the error is negative, but not when the error is positive, and calculates a sum of products of the error and the weight to calculate a weighted error; and a searching section that searches for a scale factor candidate that minimizes the weighted error in the codebook.