Estimating Temperature Lapse Rate
Moving upwards in the gravity well costs energy. For a nitrogen gas molecule, this energy can come at the expense of temperature.
Assuming a nitrogen molecule with three velocity degrees of freedom, two rotation degrees of freedom, and one vibrational degree of freedom, for a maximum molecular energy of 6 * ½ kT = 3 kT. The vertical position in the gravity well is z, and the change in vertical position results in a gravitational energy change:
For diatomic nitrogen, m = 28 * 1.66e−27 kg . g = 9.8 m/s^{2}, and k = 1.38e−23 J/K (Boltzmann constant)
0 = { \Large { dE_g \over dz } } + { \Large { dE_t \over dz } }
0 = m g + 3 k { \Large { dT \over dz } }
{ \Large { dT \over dz } } =  { \Large { { m g } \over { 3 k } } } = 0.011 K / meter = 11 K / km
The measured dry adiabatic lapse rate in air is 9.8 K / km in the troposphere, so our estimate is close. The troposphere is usually moist, and water molecules are lighter, have more degrees of vibrational freedom, and phase changes from vapor to droplets emits energy, explaining why the lapse rate for moist saturated air is closer to 5.5 K / km in the troposphere.
After the water freezes out at the tropopause, water disappears from the equation and the lapse rate increases. But only for a while; when the air gets thin enough, and the UV level is high enough, ozone forms ( 3 oxygens, molecular weight 48 ) and the air is ultravioletopaque. The ozoneladen air absorbs a lot of solar UV, heating up, while the very thin CO_2_ emits little infrared, and there is no water to transport thermal energy by vertical convection.
Up in the thermosphere, hundreds of kilometers high, the thin ozone and other charged molecules and atoms may still absorb a little bit of UV, but they are mostly heated by solar wind particles. When they are thin enough, the atoms have a very long mean free path, and the few that reach thousands of kilometers altitude are selected for high velocity because they are the energetic low probability "tail" of the Maxwellian temperature distribution. The hydrogen atoms and helium molecules at very high altitudes may have enough velocity to escape out of the Earth's gravity well.
Estimating Density Scale Height
Density \rho = C n P / T where C is a constant, n is atomic weight, P is pressure. and T is temperature in Kelvins.
\partial P = \rho g \partial Z where g is gravity and Z is height.
\partial P / P = ( C n g / T ) \partial P
Scale height H = \partial y / \partial ln( P ) = T / C n g or C = T / H n g $

Earth 
Jupiter 

T 
250 K 
150 K 
actually varies with height 
g 
1 gee 
2.5 gee 

n 
29 
2.2 

H 
7.6 km 
27 km 

C 
1.13 
1.11 
arbitrary, related to Rydberg's constant 
Using C = 1.1 gives a crude estimate which we can use to estimate planetary atmosphere heights to 10% or so. Accurate computation requires understanding temperature lapse rates, gas nonidealities, etc.