Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is probably very easy for someone with more experience, but I am trying to plot only two Normal distributions, but for some reason my Method plots 4, instead of 2.

I have:

  Table[PDF[NormalDistribution[μ, σ], x],
        {μ, 6, 7}, {σ, 1, 2}],
  {x, 0, 12}, Filling -> Axis]

which plots:

enter image description here

My intention was to plot $Normal(\mu_1,\sigma_1)$ and $Normal(\mu_2,\sigma_2)$ instead of all the 4 possible combinations of them.


share|improve this question
Instead of using Table, notice that MapThread[NormalDistribution, {{6, 7}, {1, 2}}] is equal to {NormalDistribution[6, 1], NormalDistribution[7, 2]}. So you can do Plot[{##}, {x, 0, 12}, Filling -> Axis] & @@ MapThread[Composition[PDF[#, x] &, NormalDistribution], {{6, 7}, {1, 2}}] – hftf May 4 '14 at 19:05
up vote 6 down vote accepted

Perhaps simplest:

  {PDF[NormalDistribution[6, 1], x],
   PDF[NormalDistribution[7, 2], x]},
  {x, 0, 12}, Filling -> Axis]

With the following graph:

enter image description here

share|improve this answer

OR with less typing, especially when you have many such distributions:

Plot[PDF[NormalDistribution[##], x] & @@@ {{6, 1}, {7, 2}}, {x, 0, 12}, Filling -> Axis]

You can add Evaluated -> True as an Option if you want them in different colors.

Mathematica graphics

share|improve this answer

It is not very surprising that this produces the four gaussians that it does, as you're using a square Table construction. If you want to keep an explicit Table command, you can use a more refined iterator, which you can find e.g. in the Table documentation.

Table[expr, {i, {i1, i2, ...}}]

uses the successive values i1, i2, ...

The naive try is then

  Table[PDF[NormalDistribution[pars], x],
        {pars, { {6,1}, {7,2} } }],
  {x, 0, 12}, Filling -> Axis]

though of course that won't work: it will call NormalDistribution[{6,1}] instead of NormalDistribution[6,1]. This has an easy fix using Apply (the @@):

  Table[PDF[NormalDistribution@@pars, x],
        {pars, { {6,1}, {7,2} } }],
  {x, 0, 12}, Filling -> Axis]

I think this solution is the least scary in terms of the number of weird symbols involved, while it also generalizes well to situations where you have many such plots and don't want to type the full PDF[NormalDistribution[]] throughout.

share|improve this answer

Your Answer


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.