Coal mine gas adversely affects the health of workers while benefitting enterprises. Hence, the study of the distribution of gas concentrations is the basis for the prevention and control of gas hazards. According to the working face testing for gas density and using the least squares method of mathematics, combined with the use of the MATLAB software, this study utilized the curve fitting method of linear, polynomial, exponential, and logarithmic functions to fit the working face gas concentration. The function of the gas concentration and the distance of the working face from the inlet side to the return air side of the gas concentration were found to be in increasing states, with both ends of the gas concentration tending to be stable. By calculating the mean square error of the fitting curve, we determined the best scheme that can serve as a reference for the prevention and control of gas hazards.