"Note that after fitting the kde functions, we also create a 'domain' for x 'r' and use it generate the density 'p_r' by taking the exponential of the sample scores for this domain." ...