Since the inhomogeneous instrument noise can produce extra non-Gaussianity in the cosmic microwave background (CMB) anisotropy, its effect should be carefully subtracted in the primordial non-Gaussianity estimation. We calculate the probability distribution function of the CMB anisotropy for a local type of non-Gaussianity, from which the optimal estimator in the general case (inhomogeneous noise and cut sky) is obtained. The new estimator obtained here is different from the popular one, since the inhomogeneous noise and cut sky effects are completely accounted for. The CMB anisotropy in the new estimator is noise weighted. The noise weight is different from that used by the WMAP Collaboration in their 5-year data analysis. Although it is still difficult to calculate the new estimator rigorously, for the case of the slightly inhomogeneous noise, there exists a series expansion method to compute the new estimator. Each order in the series is suppressed by two factors, (({sigma}{sup 2}/{sigma}{sub i}{sup 2})-1) and (C{sub l}/C{sub l}{sup tot}), which make the method feasible. Through the Edgeworth expansion we can generalize our discussion to other types of non-Gaussianity.