A medical ventilator with a pneumonia and pneumonia bacterial disease analysis function by using gas recognition includes a sensor array, a sensor circuit, a stochastic neural network chip, a memory and a microcontroller. The sensor array detects a plurality of gases under test and generates a plurality of recognition signals corresponding to the gases under test. The sensor circuit reads and analyzes the recognition signals to generate a plurality of gas pattern signals corresponding to the gases under test. The stochastic neural network chip reduces a dimension of the gas pattern signals to generate an analysis result. The memory stores gas training data. The microcontroller receives the analysis result, and identifies types of the gases under test according to the analysis result.