Re: Percentiles

"John Darrington" <[email protected]> Fri, 26 Mar 2004 18:42:40 +0800
Newsgroups gmane.comp.gnu.fiasco.devel
Message-ID <[email protected]>
--===============1438116791==
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="bg08WKrSYDhXBjb5"
Content-Disposition: inline


--bg08WKrSYDhXBjb5
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Mar 25, 2004 at 10:14:42AM -0400, Michael Kiefte wrote:

     > Then I think the way %iles are done in FREQUENCIES is wrong.  Have y=
ou
     > a general definition of the xth percentile ??
    =20
     How's this:
    =20
     double pctile(double *x, size_t n, double q)
     {
     	/* make sure q is between 0.0 and 1.0 inclusive */
    =20
     	double idx =3D (n-1)*q;
     	int lo =3D (int) idx;
     	sort(x, n);
    =20
     	if (idx =3D=3D lo) /* a q of 1.0 will be caught here */
     		return x[lo];
     	/* else */
     	return x[lo] + (x[lo+1]-x[lo]) * (idx-lo);
     }
    =20
By this algorithm, the 0'th percentile always equals the smallest
datum.  Is that what you'd expect.

In my research these last couple of days, I've only found one
statement about percentiles with which I wholly concur:=20

 "There is no universally accepted definition of a percentile"

This comes from http://cnx.rice.edu/content/m10805/latest/ which has
some interesting discussions.

Anyway, I'm running with Michael's definition and I'll have something
checked in soon.

J'



--=20
PGP Public key ID: 1024D/2DE827B3=20
fingerprint =3D 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://wwwkeys.pgp.net or any PGP keyserver for public key.



--bg08WKrSYDhXBjb5
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQFAZAkgimdxnC3oJ7MRAoR7AJ0WYAm584w/KMM7XUiRQpVxQnB6QQCfat7q
kJZBNOeDlgyRyUDd+PZT4e0=
=NTEd
-----END PGP SIGNATURE-----

--bg08WKrSYDhXBjb5--



--===============1438116791==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
pspp-dev mailing list
[email protected]
http://mail.gnu.org/mailman/listinfo/pspp-dev

--===============1438116791==--