Trying to write Algo-1 computeAggObsDist