normalized distance distribution and plotting scripts