Density estimation from local structure