MathGroup Archive 1996

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

Search the Archive

Re: quartile

  • Subject: [mg3374] Re: quartile
  • From: withoff (David Withoff)
  • Date: 2 Mar 1996 10:44:02 -0600
  • Approved: usenet@wri.com
  • Distribution: local
  • Newsgroups: wri.mathgroup
  • Organization: Wolfram Research, Inc.
  • Sender: daemon at wri.com

In article <4h1392$rr4 at dragonfly.wolfram.com> bryce at dgi.com (Bryce Kelly)  
writes:
> On Mathematica's definition of a quartile.
> 
> Hello All,
> 
> I need some help on the definition of a quartile. I have run into the
> following problem on different definitions for quartiles between Maple
> and Mathematica .
> 
> Using Mathematica 2.2.1
> In[] := <<Statistic`DescriptiveStatistics`
> In[] := data = {10,20,30,40,50,60,70,80}
> In[] := Median[data]
> Out[] = 45
> In[] := Quartiles[data]
> Out[] = {25,45,65}
> 
> Using Maple V release 4
> > data := [10,20,30,40,50,60,70,80]:
> > with(stats):
> > with(describe):
> > median(data);
> 		45
> > quartiles := [seq(describe[quartile[i]],i=1..3)]:
> > quartiles(data);
> 		[20,40,60]
> 
> What is Mathematica source for the definition of a quartile ?
> 
> Thanks
> 
> Bryce
> bryce at dgi.com
> 		

You can find the definition for Quartile in the 
Statistic`DescriptiveStatistics` package.  It's only
about 20 lines of relatively simple Mathematica code.

If you don't like that definition you can make up your
own to behave like the Maple function.  If you wish you
could use this to replace the definition in the
Statistic`DescriptiveStatistics` package.

In[1]:= quartiles[p_List] := With[{s = Sort[p], n = Length[p]},
             {s[[Floor[n/4]]], s[[Floor[n/2]]], s[[Floor[3 n/4]]]}]

In[2]:= data = {10,20,30,40,50,60,70,80}

Out[2]= {10, 20, 30, 40, 50, 60, 70, 80}

In[3]:= quartiles[data]

Out[3]= {20, 40, 60}

The statisticians we've talked to so far tell us that they're
happy with the Mathematica definition, but if we received some
authoritative suggestions to the effect that it should behave
otherwise, we would of course consider changing it.

Dave Withoff
Research and Development
Wolfram Research


  • Prev by Date: Re: quartile
  • Next by Date: Re: Q: How to force an Equal[]
  • Previous by thread: Re: quartile
  • Next by thread: Re: Q: How to force an Equal[]