Gas flow through layers of porous materials plays a crucial role in technical applications, geology, petrochemistry, and space sciences (e.g., fuel cells, catalysis, shale gas production, and outgassing of volatiles from comets). In many applications the Knudsen regime is predominant, where the pore size is small compared to the mean free path between intermolecular collisions. In this context common parameters to describe the gas percolation through layers of porous media are the probability of gas molecule transmission and the Knudsen diffusion coefficient of the medium. We show how probabilistic considerations on layer partitions lead to the analytical description of the permeability of a porous medium to gas flow as a function of layer thickness. The derivations are made on the preconditions that the molecule reflection at pore surfaces is diffuse and that the pore structure is homogenous on a scale much larger than the pore size. By applying a bi-hemispherical Maxwell distribution, relations between the layer transmission probability, the half-transmission thickness, and the Knudsen diffusion coefficient are obtained. For packings of spheres, expressions of these parameters in terms of porosity and grain size are derived and compared with former standard models. A verification of the derived equations is given by means of numerical simulations, also providing evidence that our analytical model for sphere packing is more accurate than the former classical models.