Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'd been doing my own convolutions of distributions for some calculations, decided to use built-ins.

With

p5 = TransformedDistribution[py + pz, 
  {Distributed[py, BinomialDistribution[7, .2]], 
   Distributed[pz, BinomialDistribution[7, .3]]}]

PDF[p5, 5]

getting the PDF takes an inordinate amount of time (as in 30+ seconds on the laptop I'm on at the moment, faster on my real machines of course, but still slow.)

I'm guessing it is using DiscreteConvolve under the covers, which is itself inordinately slow IMO, but I'm pondering if I'm missing something obvious in the use of TransformedDistribution.

Any ideas (or explanations) for the slowness appreciated.

share|improve this question
1  
On my 64-bit Windows 7 machine this takes about .7 seconds for version 8.0.4 and 9.0.1. What system are you using? –  Andy Ross Mar 16 '13 at 22:42
    
PDF[p5, 5] takes 2.4 seconds on my rather elderly iMac. –  m_goldberg Mar 16 '13 at 22:46
1  
@Andy & m_goldberg: There was a typo in original example, argument to PDF I used was 5, rather than 2. I am on 9.0.1, but as I said timing was on a crippled laptop, it is a few seconds on my normal machines, but that still seems awfully low. I'm getting the feeling though that this is just a slow operation, and for real work I'm better off doing explicit optimized convolutions of the individual PDFs. Btw, thanks for cleaning up post if one of you did it... –  HeyCarNut Mar 16 '13 at 22:50
    
My timings didn't change by using 5 instead of 2. That said, I'm on a machine with 32GB memory with a fairly fast (4.3GHz) cpu. –  Andy Ross Mar 16 '13 at 22:56
    
Read my comment again. I tested with PDF[p5, 5]. –  m_goldberg Mar 16 '13 at 23:06

1 Answer 1

Looking under the covers it creates (as expected) a piecewise function by sum for tuples of each possible combination of m summing to n for each n in PDF[dist,n], so it just needs horsepower.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.