The problem of diffusion in a porous medium with a spatially varying porosity is considered. The particular microstructure analyzed comprises a collection of impenetrable spheres, though the methods developed are general. Two different approaches for calculating the effective diffusion coefficient as a function of the microstructure are presented. The first is a deterministic approach based on the method of multiple scales; the second is a stochastic approach for small volume fraction of spheres based on matched asymptotic expansions. We compare the two approaches, and we show good agreement between them in a number of example configurations.