Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7932

Re: plotting histograms with do loop

From Bill Rowe <readnews@sbcglobal.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: plotting histograms with do loop
Date 2012-01-17 08:49 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jf3clu$nnl$1@smc.vnet.net> (permalink)

Show all headers | View raw


On 1/16/12 at 5:13 PM, hanciong@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]

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: plotting histograms with do loop Bill Rowe <readnews@sbcglobal.net> - 2012-01-17 08:49 +0000

csiph-web