The levels of air pressure and air density in the atmosphere depend on the altitude, the amount and composition of the atmosphere and the temperature profile. Atmospheric pressure, density and temperature are related via the ideal gas law.
We can't measure the amount of atmosphere directly, but we can measure a rough temperature profile with balloons. The overall dependence of atmospheric pressure with altitude can be derived by observing the pressures acting on a small volume. Using calculus we can then derive the pressure curve for the whole atmosphere. Using the temperature profile and the ideal gas law we can also derive the density gradient from the pressure gradient.
(1) 
 
where^{'} 

(2)  
where^{'} 

Using the ideal gas law (1) we can replace the density in (2) by the pressure to get the following differential equation:
(3) 
The differential equation (3) can be solved for the pressure gradient nummerically. In this case g and T can be arbitrary functions or measurements. Nummerically we solve the following equation iteratively:
(4)  
with  
and 
We begin with some start conditions, which could be measurements, for P_{0}(h_{0}), g_{0}(h_{0}), T_{0}(h_{0}). After each iteration we get the new pressure for the next height increment and we may have different g and T values. There are more complicated ways for nummerical integrations, that yield more accuracy.
If we make the simplifying assumptions that g is constant for the height range we want to solve for and T is constant or a linear function of h, we can solve the differential equation (5) analytically.
(5) 
We can bring the pressure P from the right side to the left side, so we have all pressure terms on the left, which simplifies solving the differential equation:
(6) 

Note: Pressure and temperature are commonly dependent on altitude. The temperature has to be measured empirically. It can also be constant over some altitude range.
In the International Standard Atmosphere model the empirically measured temperature is divided into some ranges and approximated either as constant (isotherm) or linearly dependent on altitude.
Lets first derive the pressure equation for the simpler case of constant temperature.
We can solve (6) by integrating both sides. The integration ∫ 1/P dP = ln(P) is applied to the left side, the integration of the right side is straight forward A · ∫ dh = A·h:
(7)  
(8) 
Applying the limits:
(9) 
P_{ref} is constant. Lets bring it to the right hand side:
(10) 
To get rid of the logarithms we raise both sides to the power of e, because e^{ln(X)} = X:
(11) 
Applying e^{ln(C)−X} = e^{ln(C)} · e^{−X} we get:
(12) 
So we get finally the formula for pressure:
(13) 
 
where^{'} 

This formula makes the simplification that the gravitational acceleration g is constant in the altitude range h_{ref} ... h.
We start again with the differential equation derived at (6), repeated here:
(14) 
But this time temperature T is not constant, but a linear function of altitude h, so that T(h_{ref}) = T_{ref}:
(15) 
Inserting (15) into (14) we get the new differential equation:
(16) 
We can solve (16) by integrating both sides. The general integral ∫ (1/X) dX = ln(X) is applied to both sides:
(17)  
(18) 
Putting in the limits yields:
(19) 
Applying ln(A) − ln(B) = ln(A/B) on the right hand side and bringing the constant ln(P_{ref}) to the right hand side yields:
(20)  
with 
To get rid of the logarithms we raise both sides to the power of e:
(21) 
Applying e^{ln(P)−X} = e^{ln(P)} · e^{−X} = P · e^{−X} we get:
(22) 
Applying e^{−β·ln(X)} = e^{ln(X)·(−β)} = (e^{ln(X)})^{−β} = X^{−β} we finally get our formula for pressure in the case of a linear temperature gradient:
(23) 
 
with  
where^{'} 
