computeDensity function

computeDensity