MathGroup Archive 2005

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

Search the Archive

Re: Re: finding out what Automatic was


normdata = RandomArray[NormalDistribution[], 100];
hist = Histogram[normdata];
binLimits = Union@Flatten@Cases[hist,
      Rectangle[{left_, _}, {right_, _}] -> {left, right}, Infinity]

{-3., -2.5, -2., -1.5, -1., -0.5, 0., 0.5, 1., 1.5, 2., 2.5}

Bobby

On Mon, 14 Feb 2005 21:50:35 -0500 (EST), Chris Chiasson <chris.chiasson at gmail.com> wrote:

> Your question seems like a good one to me, probably because I don't
> know the answer :]
>
> However, given that the category intervalas by the histogram command
> are in the form of rectangles, one could just extract them. The first
> three lines of the code that follow are directly from the help file
> entry that contains the Histogram function description. Please accept
> my apologies if you already understand the concepts involved in this
> code. This code may be evaluated one line at a time for clarity.
>
> Needs["Statistics`NormalDistribution`"]
>
> normdata=RandomArray[NormalDistribution[],100]
>
> Needs["Graphics`Graphics`"]
>
> hist=Histogram[normdata]
>
> (*hist is a graphics object - the next line shows the internal
> structure of hist*)
>
> hist//FullForm
>
> (*notice everything fis the form h[argument1,argument2,etc], which can
> be thought of as functions*)
>
> {3,2,1}//FullForm
>
> List[3,2,1]//FullForm
>
> f[x,y,z]//FullForm
>
> (*notice the similarity between lists and everyday functions that have
> not evaluated their parameters*)
>
> (*There are commands for extracting objects at different "depths" of
> nested functions.*)
>
> (*the relevant objects we would like to extract are the rectangle
> functions, which are located on level 4 of the hist graphics object*)
>
> Level[hist,{4}]
>
> (*note how the 4 is inisde brackets, just passing a plain 4 will give
> everything down to that level, not just the level itself*)
>
> (*how many levels of nested functions are there in this graphics object*)
>
> Depth[hist]
>
> Level[hist,Depth[hist]]
>
> (*most commands have a parameter allowing one to specify the level at
> which one wants to operate, rather than having to wrap the arguments
> in Level functions*)
>
> (*the parameter we need to supply is the last argument in the case statement*)
>
> (*why would we need to use a case statement? well -- we need to
> extract the rectangle functions and they happen to fit a pattern.case
> statements extract objects that fit particular patterns from other
> objects (heh,at least in mathematica:])*)
>
> (*so we first define the pattern*)
>
> Set[thepattern,
>   Rectangle[List[Pattern[xmin,Blank[]],Pattern[ymin,Blank[]]],
>     List[Pattern[xmax,Blank[]],Pattern[ymax,Blank[]]]]]
>
> (*note this could also be written thepattern=
>     Rectangle[{xmin_,ymin_},{xmax_,ymax_}]*)
>
> (*since we don't really care what level the rectangle functions are at
> inside hist,,just supply the Depth[hist] for the level argument...
> this will have the effect of searching for the rectangle pattern at
> all levels*)
>
> Set[thecases,Cases[hist,thepattern,Depth[hist]]]
>
> (*note this could also be written Cases[hist,thepattern,Depth[hist]]*)
>
> Set[thesplits,ReplaceAll[thecases,Rule[thepattern,List[xmin,xmax]]]]
>
> thesplits//FullForm
>
> (*the above command gives you the list of bin splits-- it could also
> be written as thesplits=thecases/.thepattern\[Rule]{xmin,xmax}*)
>
> Regards,
>
> On Sun, 13 Feb 2005 22:17:16 -0500 (EST), Curt Fischer
> <tentrillion at gmail.nospam.com> wrote:
>> Dear Group:
>>
>> How do you find out what value Mathematica has picked for an option set
>> to "Automatic", especially when making graphs?
>>
>> For example, I want to access the frequency data for a Histogram[] I
>> made from a list of 50000 integers.  How do I figure out which bin sizes
>> Histogram[] picked if I don't explicitly specify the bin sizes?
>>
>> Thanks.
>>
>> --
>> Curt Fischer
>>
>>
>
>



-- 
DrBob at bigfoot.com
www.eclecticdreams.net


  • Prev by Date: Re: Re: Re: 64-bit pentium
  • Next by Date: Re: Re: Using Select with arrays? (Relative newbie)
  • Previous by thread: Re: finding out what Automatic was
  • Next by thread: 2D-Plot Colorings