2
$\begingroup$

I would like to plot the graph of the sum of two random variables.So, I wrote

Plot[PDF[NormalDistribution[0, 1]+NormalDistribution[0, 1], x], {x, -10, 10}]

Why doesn't it work?

$\endgroup$
  • $\begingroup$ Also, if you need exactly what you tried to execute you can use Plot[PDF[NormalDistribution[0, 1], x] + PDF[NormalDistribution[0, 1], x], {x, -10, 10}, Filling -> Axis, PlotRange -> All] $\endgroup$ – Sektor Feb 5 '14 at 22:25
  • $\begingroup$ And also thanks to Szabolcs for the MixtureDistribution command. ;) $\endgroup$ – An old man in the sea. Feb 5 '14 at 22:31
  • $\begingroup$ @Anoldmaninthesea. Actually I was very stupid and gave you an incorrect answer. I apologize. I corrected it now. $\endgroup$ – Szabolcs Feb 5 '14 at 22:32
  • $\begingroup$ No worries. Thanks for the help. =) $\endgroup$ – An old man in the sea. Feb 5 '14 at 22:44
5
$\begingroup$

You'll need to use TransformedDistribution to achieve this:

d = TransformedDistribution[
   a + b, 
   {a \[Distributed] NormalDistribution[0, 1], b \[Distributed] NormalDistribution[2, 2]}]

(* ==> NormalDistribution[2, Sqrt[5]] *)

This represents the distribution of a+b if a is distributed according to NormalDistribution[0, 1] and b is distributed according to NormalDistribution[2, 2].

In this case the result is automatically simplified to another NormalDistribution, but it can be used in cases when it can't be automatically simplified as well.

As usual, you can obtain the PDF using PDF[d, x], and then plot it.

$\endgroup$
-1
$\begingroup$

You can also try

Plot[PDF[NormalDistribution[0, 1], x] + 
  PDF[NormalDistribution[0, 1], x], {x, -10, 10}, PlotRange -> All]

so just make each Normal Distribution it's own PDF.

$\endgroup$
  • $\begingroup$ This is incorrect. The OP wanted the PDF of the sum of two random variables, not the sum of two PDFs. $\endgroup$ – Simon Woods Sep 10 '14 at 12:36

Your Answer

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

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