An encoder comprising: a scale that includes a pattern row that has a plurality of patterns configured to spatially modulate an energy distribution; a detector array that includes a plurality of detectors that are configured to detect the energy distribution from the pattern row and arranged in a moving direction, the detector array and the scale being configured to move relatively to each other; and a signal processor configured to process and convert, into positional information, an output signal from each of the plurality of detectors of the detector array, wherein the pattern row has a first pattern having a first modulation period and a second pattern having a second modulation period different from the first modulation period in the moving direction, characterized in that the signal processor includes a first phase acquirer configured to acquire a first phase of the first modulation period based on the output signal from each of the plurality of detectors of the detector array, the encoder further comprises a weighting unit configured to weight the output signal from each of the plurality of detectors using a weight that depends on a position of a respective detector of the detector array, and the weight, which is used by the weighting unit for weighting the output signal from a respective detector of the detector array, is set so that a value of a spatial frequency response of the first phase acquirer when the output signal from each of the plurality of detectors is weighted by the weighting unit, in a predetermined range that contains a spatial frequency corresponding to the second modulation period, is smaller than that when the output signal from each of the plurality of detectors is not weighted by the weighting unit. a scale that includes a pattern row that has a plurality of patterns configured to spatially modulate an energy distribution; a detector array that includes a plurality of detectors that are configured to detect the energy distribution from the pattern row and arranged in a moving direction, the detector array and the scale being configured to move relatively to each other; and a signal processor configured to process and convert, into positional information, an output signal from each of the plurality of detectors of the detector array, wherein the pattern row has a first pattern having a first modulation period and a second pattern having a second modulation period different from the first modulation period in the moving direction, characterized in that the signal processor includes a first phase acquirer configured to acquire a first phase of the first modulation period based on the output signal from each of the plurality of detectors of the detector array, the encoder further comprises a weighting unit configured to weight the output signal from each of the plurality of detectors using a weight that depends on a position of a respective detector of the detector array, and the weight, which is used by the weighting unit for weighting the output signal from a respective detector of the detector array, is set so that a value of a spatial frequency response of the first phase acquirer when the output signal from each of the plurality of detectors is weighted by the weighting unit, in a predetermined range that contains a spatial frequency corresponding to the second modulation period, is smaller than that when the output signal from each of the plurality of detectors is not weighted by the weighting unit.