Skip to main content
edited tags
Link
kjetil b halvorsen
  • 82.8k
  • 32
  • 201
  • 663
Source Link
Tim
  • 141.2k
  • 26
  • 270
  • 512

Best way to check implementation of density, distribution function and random generation

What is the best way to check if implementation of density, distribution function, quantile function and random generation for some distribution are correct? For example, base R lacks Laplace distribution. Let's say we implement it. We can use random generation function and check if generated values are "similar" to density and distribution functions, but this is quite idem per idem kind of check. We know that if $X,Y \sim \mathrm{Exp}(\lambda)$ then $X-Y \sim \mathrm{Laplace}(0, \lambda^{-1})$, so we can generate exponential distributed values and use them to imitate Laplace distribution, however how do we know that we are close enough? We can check also if $X = F_X^{-1}(F_X(X))$, but what more? What other issues need to be checked (e.g. underflow or overflow) and what are the best practices?