MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: plotting histograms with do loop

  • To: mathgroup at smc.vnet.net
  • Subject: [mg124355] Re: plotting histograms with do loop
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Tue, 17 Jan 2012 03:32:08 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

On 1/16/12 at 5:13 PM, hanciong at gmail.com (hanciong awesome) wrote:

>hello all, I want to plot several histograms with do-loop. It is
>histogram of normal distribution, all with mean zeros, and standard
>deviation successively increasing from 1 to 5. I do the following:

>Do[   Histogram[RandomReal[NormalDistribution[0, i], 500]],
>{i, 1, 5}  ]

>But it doesn't give anything. could anyone help me? Thanx

By design, Do does not return anything. So, if you want
something to display at each iteration use Print. That is:

Do[Print@Histogram[RandomReal[NormalDistribution[0, i], 500]],
  {i, 1, 5}  ]

will output the desired 5 histograms. But do note, using Print
won't give you something you can manipulate in later
computations. So, a better approach might be:

GraphicsColumn[
  Histogram[RandomReal[NormalDistribution[0, #], 500]] & /@ Range[5],
  ImageSize -> Large]




  • Prev by Date: Re: opposite of AppendTo
  • Next by Date: Re: NDSolve output without interpolating function
  • Previous by thread: Re: plotting histograms with do loop
  • Next by thread: opposite of AppendTo