title: Follow up to: TransformedDistribution in Mathematica
body: <p>I have a follow up question to Sasha's answer of my earlier question at <a href="https://stackoverflow.com/questions/5171742/transformeddistribution-in-mathematica">TransformedDistribution in Mathematica</a>.</p>
  
  <p>As I already accepted the answer a while back, I thought it made sense to ask this as a new question.</p>
  
  <p>As part of the answer Sasha defined 2 functions:</p>
  
  <pre><code>LogNormalStableCDF[{alpha_, beta_, gamma_, sigma_, delta_}, x_Real] := 
   Block[{u}, 
    NExpectation[
     CDF[StableDistribution[alpha, beta, gamma, sigma], (x - delta)/u], 
     u \[Distributed] LogNormalDistribution[Log[gamma], sigma]]]
  
  LogNormalStablePDF[{alpha_, beta_, gamma_, sigma_, delta_}, x_Real] := 
   Block[{u}, 
    NExpectation[
     PDF[StableDistribution[alpha, beta, gamma, sigma], (x - delta)/u]/u, 
     u \[Distributed] LogNormalDistribution[Log[gamma], sigma]]]
  </code></pre>
  
  <p>The PDF function seems to work fine:</p>
  
  <pre><code>Plot[LogNormalStablePDF[{1.5, 1, 1, 0.5, 1}, x], {x, -4, 6}, 
   PlotRange -&gt; All]
  </code></pre>
  
  <p>But if I try to plot the CDF variation:</p>
  
  <pre><code>Plot[LogNormalStableCDF[{1.5, 1, 1, 0.5, 1}, x], {x, -4, 6}, 
   PlotRange -&gt; All]
  </code></pre>
  
  <p>The evaluation doesn't seem to ever finish.</p>
  
  <p>I've done something similar with the following - substituting a NormalDistribution for the StableDistribution above:</p>
  
  <pre><code>LogNormalNormalCDF[{gamma_, sigma_, delta_}, x_Real] := 
   Block[{u},
    NExpectation[CDF[NormalDistribution[0, Sqrt[2]], (x - delta)/u], 
     u \[Distributed] LogNormalDistribution[Log[gamma], sigma]]]
  
  LogNormalNormalPDF[{gamma_, sigma_, delta_}, x_Real] := 
   Block[{u}, 
    NExpectation[PDF[NormalDistribution[0, Sqrt[2]], (x - delta)/u]/u, 
     u \[Distributed] LogNormalDistribution[Log[gamma], sigma]]]
  </code></pre>
  
  <p>The plots of both the CDF and PDF versions work fine.  </p>
  
  <pre><code>Plot[LogNormalNormalPDF[{0.01, 0.4, 0.0003}, x], {x, -0.10, 0.10}, PlotRange -&gt; All]
  Plot[LogNormalNormalCDF[{0.01, 0.4, 0.0003}, x], {x, -0.10, 0.10}, PlotRange -&gt; All]
  </code></pre>
  
  <p>This has me puzzled.  Clearly the general approach works in the LogNormalNormalCDF case.  Also, the LogNormalStablePDF and LogNormalStableCDF are almost identical.  In fact from the code itself, the CDF version seems to have to do less than the PDF version.  </p>
  
  <p>So, I hoped someone could:</p>
  
  <ol>
  <li><p>explain why the LogNormalStableCDF doesn't appear to work (at least in what I consider a reasonable time, I'll try running it over night and see if it ever completes the evaluation) and</p></li>
  <li><p>suggest a way for the get LogNormalStableCDF to work more quickly.</p></li>
  </ol>
  
  <p>Many thanks,
  J.</p>