Dynamic structural analysis often requires the selection of input ground motions with a target mean response spectrum. The variance of the target response spectrum is usually ignored or accounted for in an ad hoc manner, which can bias the structural response estimates. This manuscript proposes a computationally efficient and theoretically consistent algorithm to select ground motions that match the target response spectrum mean and variance. The selection algorithm probabilistically generates multiple response spectra froma target distribution, and then selects recorded ground motions whose response spectra individually match the simulated response spectra. A greedy optimization technique further improves the match between the target and the sample means and variances. The proposed algorithm is used to select ground motions for the analysis of sample structures in order to assess the impact of considering groundmotion variance on the structural response estimates. The implications for codebased design and performance-based earthquake engineering are discussed.