Skip to main content
edited tags
Link
Tweeted twitter.com/StackMma/status/883245645477421056
Source Link
Edmund
  • 43.2k
  • 3
  • 53
  • 148

RandomVariate of ProbabilityDistribution returns values outside the support of a CDF (non-symmetric PDF)

From this post (95069) I can see that this question has been been given a workaround for symmetric PDFs and that the bug was eventually addressed. I checked and the fix is still in place for my current version 11.1.0.

My issue is that I am working with the CDF of the Generalised Pareto Distribution with is not symmetric and I am getting a similar issue.

With the CDF

ClearAll[genParetoCDF]; 
genParetoCDF[μ_, ξ_, σ_, x_] := 
 Piecewise[{
  {1 - (1 + ((x - μ)*ξ)/σ)^(-ξ^(-1)), 
    (x >= μ && ξ > 0) || (μ <= x <= μ - σ/ξ && ξ < 0)}, 
  {1 - E^(-((x - μ)/σ)), 
    x >= μ && ξ == 0}
}]

I created a distribution function

ClearAll[gpdDist];
gpdDist[μ_, ξ_, σ_] := 
 ProbabilityDistribution[{"CDF", genParetoCDF[μ, ξ, σ, x]}, {x, μ, ∞}, 
  Assumptions -> {{μ, ξ, σ} ∈ Reals, σ > 0}]

It passes the basic checks including

gpdDist[μ, ξ, σ] /. ProbabilityDistribution -> Integrate
1

Creating an instance of this distribution and sampling with RandomVariate leads to values outside the support of the distribution.

dist = gpdDist[.5 10^6, .5, 1 10^6];
dist /. ProbabilityDistribution -> NIntegrate
Quantile[dist, 0.00000000001]
1.
500000.

The minimum value of the distribution is 500,000 == μ. However, RandomVariate routinely returns values far, far below μ. You may have to evaluate the lines more than once to see it occur.

Min@RandomVariate[dist, 10000]
-2.38204*10^10

and

BoxWhiskerChart[RandomVariate[dist, 10000], "Outliers"]

Mathematica graphics

Have I missed something? If not are there any workarounds?