We present a new H i mass estimator that relates (M HI/M *) to a linear combination of four galaxy properties: stellar surface mass density, color index u − r, stellar mass, and concentration index, with the scatter of individual galaxies around the mean H i mass modeled with a Gaussian distribution function. We calibrate the estimator using the xGASS sample, including both H i detection and nondetection, and constrain the model parameters through Bayesian inferences. Tests with mock catalogs demonstrate that our estimator provides unbiased H i masses for optical samples like SDSS. We apply our estimator to the SDSS spectroscopic sample to estimate the H i mass function (HIMF) of local galaxies, as well as the conditional H i mass function in galaxy groups and the H i–halo mass relation. Our HIMF agrees with the ALFALFA measurements at M HI ≳ 5 × 109 M ⊙, but with higher amplitude and a steeper slope at lower masses. We show that this discrepancy is caused primarily by the cosmic variance, which is corrected for the SDSS sample but not for ALFALFA. The total CHIMFs for all halo masses can be described by a single Schechter function, while those of central galaxies show a double-Gaussian profile. The total H i mass in a group increases monotonically with halo mass, but for central galaxies, the H i mass shows weak dependence on halo mass when M h ≳ 1012 M ☉. The observed H i–halo mass relation is not reproduced by current hydrodynamic simulations and semianalytic models of galaxy formation.