Received: from mailout03.sul.t-online.com (mailout03.sul.t-online.com [194.25.134.81]) by hub.org (8.10.1/8.10.1) with ESMTP id e6IKNfh96590 for ; Tue, 18 Jul 2000 16:23:42 -0400 (EDT) Received: from fwd06.sul.t-online.com by mailout03.sul.t-online.com with smtp id 13Edtz-00072X-04; Tue, 18 Jul 2000 22:23:39 +0200 Received: from hot.jw.home (340000654369-0001@[62.224.109.157]) by fwd06.sul.t-online.com with esmtp id 13Edtq-0eJrcGC; Tue, 18 Jul 2000 22:23:30 +0200 Received: (from wieck@localhost) by hot.jw.home (8.8.5/8.8.5) id VAA12101; Tue, 18 Jul 2000 21:35:42 +0200 From: JanWieck@t-online.de (Jan Wieck) Message-Id: <200007181935.VAA12101@hot.jw.home> Subject: Re: Median In-Reply-To: <20000705153840.73285.qmail@hotmail.com> from omid omoomi at "Jul 5, 2000 08:38:40 am" To: omid omoomi Date: Tue, 18 Jul 2000 21:35:42 +0200 (MEST) CC: BKermani@illumina.com, pgsql-sql@postgresql.org Reply-To: Jan Wieck X-Mailer: ELM [version 2.4ME+ PL68 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Sender: 340000654369-0001@t-dialin.net X-Archive-Number: 200007/176 omid omoomi wrote: > Hi, > I'll be glad if you describe more details about the problem. Is it a kind of > statistical analysis or what? > Omid Omoomi Sorry to respond that slow. It's something, Ulf Mehlig described to me a couple of months ago. The median is the value, below and above of which exactly half of the sorted items would be. Having an odd number of entries, it's exactly the one in the middle like 1 2 3 4 5 6 7 ------|------ M = 4 Having an even number of entries, it's the average between the two in the middle like 1 2 3 4 5 6 7 8 -------|------- M = (4 + 5) / 2 As he said, other ranges like Quartile (the position where 25% of the entries are below and 75% are above) would also be of interest. So the most useful thing would be an aggregate like qantil(n), where n is value between 0.0 and 100.0, so that quantil(50.0) is the Median, quantil(25.0) is the first Quartile and so on. I don't see any quick solution how to solve this problem with an aggregate. Aggregates get all selected values in unsorted order, and don't know ahead how many items there will be. Even if, all this wouldn't be of any use, because you need to look at the entire sorted list of selected items. Maybe someone else has an idea. > > >From: "Kermani, Bahram" > >To: "'pgsql-sql@postgresql.org'" > >Subject: [SQL] Median > >Date: Fri, 30 Jun 2000 17:37:06 -0700 > > > >Hello, > > > >I am trying to do a Median or Trimmed-mean operation in postgreSQL. I was > >wondering if anybody knew how to do it. I appreciate it if you reply to my > >email address. > > > >Thanks, > >Bahram Kermani > >bkermani@illumina.com > > ________________________________________________________________________ > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com > Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #================================================== JanWieck@Yahoo.com #