A method and apparatus for determining the presence of an analyte in a medium or the composition of a medium wherein a volume of material is irradiated with temporally-modulated electromagnetic energy at multiple wavelengths. The electromagnetic radiation is detected after it has traversed a portion of the material. Representation signals related to the degree of absorption of electromagnetic energy at various wavelengths in the material and signals related to the path lengths travelled by the electromagnetic radiation in the material are generated, and signals representative of the optical absorption per unit path length at various wavelengths in the medium are derived. The derived wavelength dependence of the optical absorption per unit path length is compared with a calibration model, and the comparison is analyzed to derive concentrations of specific chemical species within the material and the presence of an analyte or composition of the medium. An output indicative of the concentration and composition is then provided.