Euclidean distance between two sets of tuples

From: Surfing <onlinesurfing(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Euclidean distance between two sets of tuples
Date: 2013-02-25 18:34:10
Message-ID: 512BAEA2.9040803@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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.

Browse pgsql-sql by date

  From Date Subject
Next Message mkumbale 2013-02-25 22:49:28 Creating a new database with a TEMPLATE did not work
Previous Message Don Parris 2013-02-24 22:20:32 Using Ltree For Hierarchical Structures