The “standard” atmosphere is a model. It is artificial, but it agrees reasonably well, on average, with the real atmosphere on a cool day in temperate regions.
This is sometimes called the “International Standard Atmosphere”, and I will call it the ISA model for short.
The ISA model consists of seven layers, labeled zero through six inclusive. The properties given in the following table.
Layer  Height  Pressure  Density  Temperature  Lapse  Name  
(m)  (ft)  (Pa)  (inHg)  (kg/m^{3})  (K)  (C)  (K/m)  (K/ft)  
0  0  101325  29.92126  1.224999  288.15  15.00  Sea Level  
0  ⋮  ⋮  ⋮  ⋮  ⋮  ⋮  ⋮  0.0065  0.0019812  Troposphere  
11,000  36,089  22632.1  6.683246  0.363918  216.65  56.50  Tropopause  
1  ⋮  ⋮  ⋮  ⋮  ⋮  ⋮  ⋮  0  0  Stratosphere  
20,000  65,616  5474.89  1.616734  0.088035  216.65  56.50  
2  ⋮  ⋮  ⋮  ⋮  ⋮  ⋮  ⋮  0.0010  0.0003048  Stratosphere  
32,000  104,986  868.019  0.256326  0.013225  228.65  44.50  
3  ⋮  ⋮  ⋮  ⋮  ⋮  ⋮  ⋮  0.0028  0.0008534  Stratosphere  
47,000  154,199  110.906  0.0327506  0.001428  270.65  2.50  Stratopause  
4  ⋮  ⋮  ⋮  ⋮  ⋮  ⋮  ⋮  0  0  Mesosphere  
51,000  167,322  66.9389  0.0197670  0.000862  270.65  2.50  
5  ⋮  ⋮  ⋮  ⋮  ⋮  ⋮  ⋮  0.0028  0.0008534  Mesosphere  
71,000  232,939  3.95642  0.00116833  0.000064  214.65  58.50  
6  ⋮  ⋮  ⋮  ⋮  ⋮  ⋮  ⋮  0.0020  0.0006096  Mesosphere  
80,000  262,467  0.88628  0.000261718  0.000016  196.65  76.50  Mesopause 
The staggered rows in the table are meant to indicate the layers and the boundaries between layers; for instance, layer #1 extends from 11,000 meters to 20,000 meters, and within this layer the lapse rate is zero. At the tropopause, i.e. the boundary between layer #0 and layer #1, the pressure is 22632.1 pascals. You can compare this table with the one in reference 1.
Note: The model can be extended to altitudes below sea level. Just continue the same lapse rate as used for layer #0. To do things properly, we should add another row to the table – but it’s easier to just ignore the tabulated lower “boundary” of layer #0. It is nice to know that the model still works if you visit Amsterdam or Death Valley.Note: There is not any officiallydefined top to ISA layer #6 so far as I know, but it cannot possibly be valid outside the mesosphere. That ends at the mesopause, about 80 km up, and above that lies the thermosphere. The final row of the table gives data for 80,000 m, and marks what I consider the end of the valid range for layer #6. It is possible to build models that extend higher, but that would be beyond the scope of this document.
Generally speaking, we are interested in the temperature profile AND the density profile AND the pressure profile AND the chemical composition of the atmosphere, but when we build a simple model of the atmosphere, we cannot independently choose all four of those quantities. If we choose two of them, the other four are automatically determined by the laws of physics.
As it turns out, the folks who defined the ISA model chose to specify the temperature profile and the chemical composition.
Therefore the only quantities needed to define ISA are the following:
All the other numbers in the table can be calculated using the quantities listed above.
So, without further ado, let discuss how to compute the properties that need to be computed. We start from layer #0 and work our way up. We will need the forcebalance equation (equation 1) and the ideal gas law (equation 2).
We can view the force balance in either of two ways. The first view starts from the observation that at any height h, the pressure is equal to the weight (per unit area) of the air column above h. This makes sense in terms of conservation of momentum (aka force balance), since something has to support the weight of the air column.
Pressure is defined as force per unit area, and in this case the force is the weight of the air column.
The second view takes a more local approach, treating the air column as many parcels of air, stacked up like pancakes. Then dP is the increment of pressure contributed by a single parcel dh thick. You can see that ρdh is the mass per unit area of the parcel, ρgdh is the corresponding weight, i.e. the force of gravity. Putting this all together gives us the forcebalance equation:
 (1) 
The minus sign reflects the fact that pressure decreases as height increases.
You can easily show that the two views do in fact represent the same physics. Integrate equation 1 from h to infinity, and as a boundary condition use the fact that the pressure is zero in outer space.
Meanwhile, the ideal gas law is:
 (2) 
where we are using the following symbols:
 (3) 
So far, we have used only the general laws of physics. We now make some assumptions that are specific to the standard atmosphere. Here are the assumptions, and some comments about them:
We assume that the density is low enough that the idea gas law is valid to high precision.  This is a very wellfounded assumption. 
We postulate that the molar mass in the standard atmosphere is constant, namely m_{M} = 28.9644 grams per mole.  The molar mass of the real atmosphere varies according to humidity and other factors, but still this value of m_{M} remains a good approximation. 
We postulate that in the standard atmosphere, the pressure equals 101325 pascals when the height equals zero.  The real atmosphere often deviates significantly from this, so it will be necessary to apply an offset – the Kollsman offset – to the standard atmosphere before using it for practical applications such as altimetry. This is what ordinary altimeters do, as discussed in detail in section 2. 
Last but not least, we postulate that the lapse rate in the standard atmosphere is as specified in the table.  In the real atmosphere, there can be a significantly nonstandard lapse rate, often associated with a nonstandard temperature. In some situations, this can be handled to zeroth order using a Kollsman offset as previously mentioned ... but in other situations the zerothorder (Kollsman) approximation be dangerously misleading, as discussed in section 3. 
The lapse is expressed by the following equation, which can be immediately integrated:
 (4) 
where for any layer, λ is the lapse rate for that layer. We are also using
 (5) 
for some “reference point” within the layer. (Very commonly the reference point is taken to be the bottom of the layer, hence the subscript “b”, but actually you are free to choose any point in the layer. This freedom makes it easy to extend layer #0 to negative altitudes, as remarked above.) In the troposphere, the temperature gradient dP/dh is negative, and the lapse rate λ is a positive number.
Starting from equation 1 and plugging in equation 2 and equation 4, we arrive at:
 (6) 
which is easily integrated. For any layer in which the lapse rate is nonzero, the main result is:
 (7) 
where in the exponent we have introduced N, defined as:
 (8) 
In the troposphere, N is a positive number, N ≈ 0.1902632.
You can verify the correctness of equation 7 by differentiating both sides with respect to h and comparing it to equation 6.
In the special case where the lapse rate is zero, the main result reduces to:
 (9) 
as you can verify by direct integration of equation 6, or by differentiating both sides of equation 9 with respect to h, or by taking equation 7 in the limit as λ goes to zero, with due regard to the λdependence of N.
Out of curiosity, we can see what would happen if the bottom layer of the atmosphere were isothermal. Using the ISA sealevel temperature, we would have:
 (10) 
Let’s invert equation 7 to give height as a function of pressure. This is useful for altimetery, as discussed in section 2. In any layer where N≠0, we have:
 (11) 
Similarly, in any isothermal layer, we can invert equation 9 instead:
 (12) 
Equation 11 and equation 12 can be used to calculate the pressure altitude in the troposophere and stratosphere respectively. Compare equation 18 below. For another derivation of these formulas, see reference 2.
For a compendium of useful aviationrelated formulas, see reference 3.
In this section we look at the behavior of the standard altimeter, in particular a pressure altimeter, aka barometric altimeter, such as is found in all ordinary aircraft. This is a device that gives you an estimate of altitude, given the pressure. (The reverse problem of finding the pressure, given the altitude, is discussed in reference 4.)
It may not be obvious from a first look at equation 17, but we shall see that the standard altimeter is compatible with a simple generalization of the ISA model. The generalization is simple but important. The altimeter can reproduce the standard atmosphere, but it can and must do other things besides.
In the real world, nonISA atmospheric conditions are the rule, not the exception. Therefore the altimeter has an adjustment, called the “altimeter setting” (aka “Kollsman window”), which makes a zeroth order correction for nonstandard conditions. Firstorder and higher corrections are not handled by the instrument, and can cause deceptive readings, as discussed in section 3. The pilot must be aware of the needed corrections, and must apply them “by hand” when necessary.
The main desirable features an aircraft altimeter should have include:
Approach to landing: An aircraft approaching a field for landing should be able to use the altimeter to get a reasonably accurate idea of height relative to the field.  Real altimeters achieve this rather well. Using the proper altimeter setting, an altimeter in an aircraft sitting on the runway should indicate the elevation of the runway. There is nothing in the system that prevents this from being accurate within a few feet, although in practice errors of 20 feet or so are common, just due to the imprecision of the devices involved. 
Air traffic separation: Two aircraft in the same area should be able to use their altimeters for vertical separation. That is, a significant difference in indicated altitude should guarantee a significant difference in true altitude.  This, too, is well achieved, assuming everybody in the area is using the same altimeter setting. 
Obstruction clearance: Ideally, a pilot would be able to rely on the altimeter to judge height relative to terrain or obstructions.  Alas, this is only very imperfectly achieved, particularly when the atmospheric temperature is different from standard, because nonstandard temperature is associated with a nonstandard pressure gradient dP/dh. This is particularly dangerous in cold weather, because the altimeter suggests that the aircraft is higher than it really is. 
Let’s cut to the chase. The formula that the FAA uses for calculating altimeter setting values is:
 (13) 
where
 (14) 
For details on the terminology, see section 3.2. It is sometimes useful to solve for the field pressure in terms of the altimeter setting:
 (15) 
The N′ used in these equations is very nearly equal to the N defined by equation 8, just rounded off. Similarly, we can calculate a K value according to
We obtain equation 16b by setting T_{b} and P_{b} to the standard sealevel temperature and pressure, in accordance with equation 5.
You can see that the K′ defined by equation 14 is a roundedoff version of the tropospheric K. Now it turns out that by using K′ and N′ instead of K and N, the error is negligible anywhere within the troposphere. It corresponds to moving the height of the AWOS machine up or down by 1.5 inches or less. This is orders of magnitude smaller than other nonidealities built into the system. (It turns out that the error due to rounding off K largely cancels the error due to rounding off N, so rounding off both is better than rounding off either one separately.) Therefore we will drop the primes and take equation 17 as the exact pressurealtimetry equation. We consider the primed quantities in equation 14 to be approximations – very good approximations.
 (17) 
One property that aircraft altimeters really, really ought to have is that if you sit on the field and set the altimeter setting according to equation 17, the altimeter should indicate field elevation. This means that all altimeters are closely constrained by equation 17. Perhaps surprisingly, this one simple fact allows us to deduce much of the other behavior of the altimeter. Let’s pursue this idea:
Equation 17 is one equation in three variables. If we rearrange it to show how the elevation depends on the other variables, we obtain:
 (18) 
where h_{I} is the indicated altitude, i.e. the reading that would be indicated by an ideal altimeter, and S is the actual altimeter setting.
You can perform a useful check by setting S equal to the Q_{NH} defined by equation 17, and plugging that value into equation 18. That setting guarantees that if your static pressure P is equal to the field pressure P_{a}, then your indicated altitude h_{I} will be equal to the field elevation h_{a}.
You can also verify that if you set S = P_{b} then equation 18 has the same form as equation 11 above. That means our altimetry formula is consistent with the tropospheric part of the standard atmosphere, if you use the standard Q_{NH} value, S = P_{b} (i.e. 29.92126 inHg).
One amusing property of equation 18 is that the altimeter setting has a purely additive effect on the indicated altitude. That is, within the troposphere we can rewrite things as:

where C denotes the correction applied by choosing an altimeter setting different from 29.92 inHg.
We now introduce the notion of pressure altitude. For any given pressure, the corresponding pressure altitude is the height in the standard atmosphere at which that pressure would be found. This is a purely mathematical conversion, completely independent of current weather conditions.
In equation 19a, if we set C=0, what remains is the same as equation 11, and can be used to calculate the pressure altitude. More generally, −C is the difference between your indicated altitude and your pressure altitude. The minus sign reflects the fact that higher pressure corresponds to lower altitude, and vice versa.
This is simple and in some ways convenient, because (apart from constants), the squarebracketed term on the first line of equation 19 depends only on the pressure P, while the corresponding term on the second line depends only on the altimeter setting S.
However, this simplicity is also a major limitation. We see that the altimeter can only model a particular type of departure from the ISA model, namely a departure that corresponds to a “rigid shift”. That is, using a Q_{NH} other than 29.92 corresponds to taking the entire atmosphere and shifting it, as a whole, up or down. We can call this a Kollsman model; it is more general than the ISA model, and includes the ISA model as a special case.
The previous few paragraphs assume N≠0. Note that the whole idea of altimeter setting only applies within the troposphere, because in flight above 18,000 feet, the Kollsman window is always set to the standard 29.92 inHg. There are no established airfields and no METAR reporting stations above 18,000 feet.
On the other hand, there is plenty of terrain above 18,000 feet. You have to be careful when using a barometric altimeter for terrain clearance above 18,000 feet. Even below 18,000 feet, you need to be careful if the real atmosphere is colder than the standard atmosphere.
Also, the idea of pressure altitude applies at all altitudes, and is routinely used for vertical separation of air traffic. In the stratosphere, the pressure altitude can be determined using equation 12.
The altimeter is not capable of modeling anything other than the Kollsman model, i.e. the ISA model plus a rigid shift. In particular, it does not do a good job of modeling an atmosphere with a nonISA densityversuspressure relationship. The ideal gas law (equation 2) tells us that a nonISA temperature profile will give us a nonISA density profile. (High absolute humidity can also cause a nonISA density profile; for details on this, see reference 5.)
Imagine that we have five airports and five different elevations, namely 0, 2500, 5000, 7500, and 10,000 feet MSL.
All five airports are in the same airmass. Also, in all of the following scenarios, pressure at sea level (P_{SL}) of this airmass is equal to the standard value, 29.92 inHg, so we don’t need to worry about that.
In the first scenario we consider, the airmass has standard temperature. The following table shows the altimeter setting and other information as a function of altitude. It is completely boring. In the first scenario, the altimeter setting Q_{NH} is found to be the same throughout the airmass.
Scenario 1: tref: 288.15 A: 0 Aind: 1 Apr: 0 P: 29.92 Psl: 29.92 Qnh: 29.92 A: 2500 Aind: 2498 Apr: 2499 P: 27.32 Psl: 29.92 Qnh: 29.92 A: 5000 Aind: 4998 Apr: 5000 P: 24.90 Psl: 29.92 Qnh: 29.92 A: 7500 Aind: 7498 Apr: 7499 P: 22.65 Psl: 29.92 Qnh: 29.92 A: 10000 Aind: 9998 Apr: 10000 P: 20.58 Psl: 29.92 Qnh: 29.92
Scenario 2: tref: 268.15 A: 0 Aind: 1 Apr: 0 P: 29.92 Psl: 29.92 Qnh: 29.92 A: 2500 Aind: 2499 Apr: 2686 P: 27.13 Psl: 29.92 Qnh: 29.72 A: 5000 Aind: 4999 Apr: 5372 P: 24.55 Psl: 29.92 Qnh: 29.52 A: 7500 Aind: 7498 Apr: 8059 P: 22.17 Psl: 29.92 Qnh: 29.32 A: 10000 Aind: 9996 Apr: 10745 P: 19.99 Psl: 29.92 Qnh: 29.12
where
 (20) 
The code to generate these tables can be found in reference 4.
The dominant reason why the indicated altitude differs from the true altitude is that the altimeter setting always gets rounded off to two digits. This introduces an error of ± 5 feet or less.
The second scenario is generated in the same way as the first, except for one thing: the airmass is now everywhere 20^{∘}C colder than standard. The lapse rate is the same; all the temperatures are shifted down together.
In the table you can see that there is a distinct difference between P_{SL} and altimeter setting. It must be emphasized that all stations have the same P_{SL}; the pressure at sea level is a property of the airmass, and in our example the airmass has a P_{SL} of 29.92 everywhere.
In contrast, the altimeter setting is not the same everywhere. This is an example of something that all pilots should be aware of. It’s called HALT, or simply HALT, which stands for High Altimeter because of Low Temperature.
If you were foolish enough to set the P_{SL} into the Kollsman window of your altimeter, in this scenario the instrument would read pressure altitude. This would cause significant problems, as you can see from the A_{pr} values in the table. When you thought you were at 10,700 feet, you would actually be below 10,000 feet.
This is not an implausible or extreme scenario; an airmass 20^{∘}C colder than standard is not particularly uncommon. Indeed airmasses considerably colder than that occur from time to time.
In general, being hundreds of feet lower than you think you are is an undesirable state of affairs.
If you need to make some compensation, you can do an approximate calculation in your head: Choose to fly at an indicated altitude that is higher than you otherwise would have chosen, by adding a percentage of your height above the station that gave you your altimeter setting. If it’s cold, add 10%. If it’s really, really cold, add 20%. Approximate compensation is a whole lot better than no compensation. For more discussion of compensation, including formulas, see reference 6.
P_{SL} denotes the actual pressure at sea level, such as you could obtain by phoning a friend at a nearby sealevel location and asking for the genuine pressure at genuine sea level.  The METAR SLP is imaginary, calculated using the artificial ISA density profile. Sometimes, the real density is “close” to the ISA density ... but often it is not, in which case the METAR SLP will be significantly different from the P_{SL}. 
You can prove that the METAR “SLP” has the same meaning as “altimeter setting”; the only difference is that METAR expresses SLP in millibars (dropping the thousandmillibar digit if any), whereas it expresses the altimeter setting in inches of mercury. I wish they wouldn’t call it SLP, since that is alltoooften confused with P_{SL}, and since better synonyms (such as Q_{NH}) are available.
To paraphrase Tolstoy, standard atmospheres are all alike, but each nonstandard atmosphere is nonstandard in its own way.
Caveat: That the “lapse rate” variable in that document (denoted L) is the negative of what we call the lapse rate variable in this document (denoted λ). Usually when something is “lapsing”, it is going away. Our λ is positive in the troposphere, to indicate that the temperature decreases as the height increases.
See previous caveat.