Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1995
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1995

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

Search the Archive

Re: histogram

  • To: mathgroup at smc.vnet.net
  • Subject: [mg2078] Re: histogram
  • From: wagner at bullwinkle.cs.Colorado.EDU (Dave Wagner)
  • Date: Sat, 23 Sep 1995 20:36:59 -0400
  • Organization: University of Colorado, Boulder

In article <DFCF7y.K3I at wri.com>,
Michael Probst <michael.probst at uibk.ac.at> wrote:
>What is the best (fastest) way to generate histograms ?

>I can use a Do[] but this seems clumsy:
>hist={0,0,0, .... };
>Do[
>  ind=myindexfunction[data[[i]]]; hist[[ind]]=hist[[ind]]+1,
>{i,1,Length[data]}]
>

You can use Scan on your data:

	Scan[hist[[myindexfunction[#]]]++ &, data]

The ++ operator takes the place of the addition and assignment.
Thus you don't need a local variable for the index anymore.

		Dave Wagner
		Principia Consulting
		(303) 786-8371
		dbwagner at princon.com
		http://www.princon.com/princon


  • Prev by Date: Re: Importingf a PICT
  • Next by Date: Dealing with Indeterminant points & ListPlot
  • Previous by thread: histogram
  • Next by thread: Re: histogram