  Consider an i.i.d. sample from an unknown density function supported on an
unknown manifold embedded in a high dimensional Euclidean space. We tackle the
problem of learning a distance between points, able to capture both the
geometry of the manifold and the underlying density. We prove the convergence
of this microscopic distance, as the sample size goes to infinity, to a
macroscopic one that we call Fermat distance as it minimizes a path functional,
resembling Fermat principle in optics. The proof boils down to the study of
geodesics in Euclidean first-passage percolation for nonhomogeneous Poisson
point processes.
