4
$\begingroup$

The two distributions are the same, except the ProbabilityDistribution cuts out below x=0. The wolfram documentation on ProbabilityDistribution says nothing about speed. A search of this site gave no obvious answer. Here is the code:

Dx = ExtremeValueDistribution[0.14068977685132567`, 
   0.10712657717044427`];
Dxp = ProbabilityDistribution[
   E^(-E^(((-x + 0.14068977685132567`)/0.10712657717044427`)) + (-x + 
     0.14068977685132567`)/0.10712657717044427`)/
   0.10712657717044427`, {x, 0, Infinity}, Method -> "Normalize"];
AbsoluteTiming[RandomVariate[Dx, 10^6];]
AbsoluteTiming[RandomVariate[Dxp, 10^6];]
$\endgroup$
  • $\begingroup$ Good question. I'd say that ProbabilityDistribution is a very general tool, so it needs a very general algorithm. I guess, when it is called with a generic function expression as firsts argument, it choses some rather general Monte-Carlo method. But if it detects one of the built-in distributions, such as ExtremeValueDistribution it can branch to a built-in algorithm that this tailored and optimized for this specific distribution. But maybe it is worth to report to Wolfram Research. Maybe they have overlooked some optimization potential in the generic branch... $\endgroup$ – Henrik Schumacher Jun 13 '18 at 18:05
  • $\begingroup$ Thanks for your suggestion, I just asked Wolfram tech support about it. $\endgroup$ – Michael B. Heaney Jun 13 '18 at 18:58
  • 2
    $\begingroup$ To generate random variates, the InverseCDF is needed. For the distribution Dx this is easily obtained: InverseCDF[Dx, q], For the distribution Dxp numeric techniques must be used. $\endgroup$ – Bob Hanlon Jun 13 '18 at 19:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.