Mathematical Foundations for Data Analysis