This version works much faster -- we read the PDF for distances into internal array first and then we approximate the PDF based on this array only.