Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jROOw-0005a1-0V for pgsql-general@arkaria.postgresql.org; Wed, 22 Apr 2020 23:03:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jROOu-0001bG-Td for pgsql-general@arkaria.postgresql.org; Wed, 22 Apr 2020 23:03:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jROOu-0001b9-Lm for pgsql-general@lists.postgresql.org; Wed, 22 Apr 2020 23:03:28 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jROOq-0004Lw-RQ for pgsql-general@lists.postgresql.org; Wed, 22 Apr 2020 23:03:27 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id E645626EE; Thu, 23 Apr 2020 01:03:22 +0200 (CEST) Date: Thu, 23 Apr 2020 01:03:22 +0200 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: How do work tercile, =?iso-8859-1?Q?pe?= =?iso-8859-1?Q?rcentile_&_funcion_percentile=5Fcont=28=29=A0=3F?= Message-ID: <20200422230322.GB4048@hjp.at> References: <1045753462.38287828.1587542449789.JavaMail.zimbra@meteo.fr> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="zx4FCpZtqtKETZ7O" Content-Disposition: inline In-Reply-To: <1045753462.38287828.1587542449789.JavaMail.zimbra@meteo.fr> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --zx4FCpZtqtKETZ7O Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2020-04-22 10:00:49 +0200, PALAYRET Jacques wrote: > From a table x(c1) containing 30 lines with integer values (column c1) fr= om 1 > to 30 : >=20 > SELECT percentile_cont(1./3) WITHIN GROUP (ORDER BY c1) FROM x ; > percentile_cont > ------------------ > 10.6666666666667 > (1 ligne) > SELECT percentile_cont(2./3) WITHIN GROUP (ORDER BY c1) FROM x ; > percentile_cont > ------------------ > 20.3333333333333 > (1 ligne) Think of the 30 values as points in a graph: The x values run from 0 to 29, the y values are your values. The points are connected with straight lines. Since your y values just increase by 1 you have a straight line =66rom (0, 1) to (29, 30) Then percentile_cont(1./3) is the value y value 1/3 along that line and percentile_cont(2./3) is the y value 2/3 along that line. So you need to find the y values corresponding to 29*(1/3) =3D 9.667 and 29*(2/3) =3D 19.3= 33. These are obviously 10.667 and 20.333 respectively. hp --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --zx4FCpZtqtKETZ7O Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAl6gzTYACgkQ8g5IURL+ KF1bcBAAnOdO4Eae6wpD2Es1tmu9d4FsLI3EJzNJA5NU1AHF61q8mX9lKAVpHDRA GHcR6xAIWhY6RyaogCnw6demSWLGNkmue+NdqNyJML5azrODmj2pNiWka7syrylx u7HBnLyYxhLoNEWRTDKKrXS3rL+P7mSDU0s7zWMXm6GBp34hL0tcuv8s7kFPZmTU pw62qLl0F3IZkI+AAm8vrACqXNjNKTxRgakg+C+t+31MEKqB5jrWhu0i/CClupcS cUMABZKgnevrzsM1bcvkJEqEkjKSSdeRfZtaG+2ks0KEWvvTfjZcehZeCU7an78Y k38Nc4kQFUAJAjTwjW687ZAku/X/x9OTo21Q5CMXDrkCZBFs4+e9jKaSacE5meCn 7j1N9wLEwLRuBMhIaz2Jx+iH2RT8t+P2b27A6l/WWeoWP6EocblegZ7KVBdSkVCU Bz44Dn3jjs8P5uKsjyiSkyhihmTJwrSAjcxq/DiRrbdcpAGLuup5wVEh0fia47r2 9T3eRdU/Dk5NmFA4yasVy1CuFQ/6y7SkIlWxjPmNr005hOVjIoDiPcc8rlN6MLWB 0czohR7AnRGZ6uHx0DDLdVffIMb7R/Jn8lZRiDqpfQH9+nVDZfd5ebnSQo9qKb0C oceYiq1kQNLWhbHkGoBNIgcukIeqEW52LdyGeUCbc1pvgOf9p54= =rzrK -----END PGP SIGNATURE----- --zx4FCpZtqtKETZ7O--