# Plotting different PDFs of a distribution in the same graph

How would I plot the PDF (probability density function) of WeibullDistribution[1/5, 50], WeibullDistribution[1/4, 40], WeibullDistribution[1/3, 30] and WeibullDistribution[1/2, 20] in the same graph?

-
There are good examples how to do this in the documentation of the {WeibullDistribution} –  Matariki May 1 '12 at 0:51

## 2 Answers

Here is a simple way. The Evaluate is needed to ensure the line colors are different (see this question for an explanation of this).

Plot[Evaluate[
PDF[WeibullDistribution[1/#, 10 #], x] & /@ Range[2, 5]], {x, 0.1, 5}]


As noted in the documentation, Plot and related functions quite happily draw multiple lines if they are given a list of functions (or data in the case of ListPlot and friends) as their first argument.

Notice the use of Map (/@) and a pure function to avoid having to type out the WeibullDistribution bit of the code multiple times. (This page in the documentation will be useful in this regard.)

-
Thank you for the link to the Map documentation, that is very useful! In this case you used "#" for both parameters. But, let's say I would want to map 1 list of values to the first parameter, and one to the second parameter, how would I do this? –  Chris May 1 '12 at 1:05
@Chris You should look up Apply (@@) and apply at level 1 (@@@). A simple example which you can extend to your case is the following: Clear[f];f[#1, #2] & @@@ Transpose[{Range[5], Range[6, 10]}] –  The Toad May 1 '12 at 1:10
@Chris: Also have a look at MapThread. But this is really a separate question. –  Verbeia May 1 '12 at 1:11

Another way to write Verbeia's code:

Plot[#, {x, 0.1, 5}] & @
Array[PDF[WeibullDistribution[1/#, 10 #], x] &, 4, 2]

-