Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UA2tO-00085V-6s for pgsql-sql@arkaria.postgresql.org; Mon, 25 Feb 2013 18:35:15 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UA2tM-0001nr-Rp for pgsql-sql@arkaria.postgresql.org; Mon, 25 Feb 2013 18:35:12 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UA2t9-0001b9-Ro for pgsql-sql@postgresql.org; Mon, 25 Feb 2013 18:35:00 +0000 Received: from mail-ee0-f54.google.com ([74.125.83.54]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UA2t7-0004aw-TW for pgsql-sql@postgresql.org; Mon, 25 Feb 2013 18:34:59 +0000 Received: by mail-ee0-f54.google.com with SMTP id c41so1552207eek.27 for ; Mon, 25 Feb 2013 10:34:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=oA8PgzIrWoOQkPuLFEdVmQdt3akl4aLfD4Hi2JY3JKw=; b=TVZhVPkTHv517vS9zVo6f8TVNKEGmgq6BiM8u/s5+sfqNV4hR7CGh2WwRrRSLvWtYF JonctaNVMb6bxWtuCmWlszBQso149qlbSUZe5Cw2xlJPtrV2vEjKOMlfWlun9ev8ROFT lCuHYAvpzZzvwtOmlL8tqu9z/lQnmVdG6WojVA6BwtwBrtCYAEqgOR13Aya4lhlRteOw 5R0nPQIdziEyZ3vjd8rTJ+CvzFw42InE1uinJjQRndPWe1FG6iaZuvTnP6qvGx0k7ydJ 0WOMj+mYEf/MIfxDqS8kRsv0ETcPr2YhM6prAljLvAy+9GHN+HCwFpnxt8q5YmgEPoJZ k4dw== X-Received: by 10.14.210.8 with SMTP id t8mr41529875eeo.35.1361817296729; Mon, 25 Feb 2013 10:34:56 -0800 (PST) Received: from [192.168.0.2] (adsl-ull-149-200.50-151.net24.it. [151.50.200.149]) by mx.google.com with ESMTPS id u44sm19750317eel.7.2013.02.25.10.34.55 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Feb 2013 10:34:55 -0800 (PST) Message-ID: <512BAEA2.9040803@gmail.com> Date: Mon, 25 Feb 2013 19:34:10 +0100 From: Surfing User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20130215 Thunderbird/17.0.3 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Euclidean distance between two sets of tuples Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org Hi all, I would like to ask if there exists a function to calculate the Euclidean distance between two rows of the same table. Obviously, the distance between two non-numeric fields should be 0 if they are the same value, 1 otherwise. In general, I need to compute an average distance between the subsets of rows, computed pairwise. Example: - Set 1: 10 rows - Set 2: 15 rows - Distances computed 150 I just need the value 1/150*(Sum of all the computed Euclidean distances). I could write a procedure, but it would be nice if there already exists a function which at least computes a single Euclidean function between two rows. Any suggestion? Thank you. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql