This actually isn't too hard. The Maxwell-Boltzmann distribution provides the average velocity of gases. The most probable speed (which is only good for order of magnitude estimates) is:
You can put in the numbers: $T$ is the temperature of the Earth's surface, about $300K$, and $m$ is the mass of whatever gas you're interested in. For example, with hydrogen, you get that the most probable velocity is about $2225 m/s$.
Compare that to Earth's escape velocity, which is calculated from Newton's laws as about $11.186 km/s$. This is much larger than the most probable velocity of hydrogen, which indicates that most hydrogen atoms would not escape. However, a substantial-enough fraction does (see the shape of the Maxwell-Boltzmann distribution). The remaining hydrogen thermalizes, which leads to more hydrogen that's moving faster than the escape velocity, etc, so that hydrogen eventually escapes the atmosphere.
You can calculate the fraction of hydrogen that's moving fast enough to escape by integrating the Maxwell-Boltzmann distribution, and the same goes for other gases.
You can also read more about the entire phenomenon at Wikipedia's article on atmospheric escape.