From: ankane (@ankane) <noreply+ankane@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #848: What's the current status of random_vector()? + Proposal for enhancement
Date: Tue, 27 May 2025 18:23:30 +0000
Message-ID: <gh-pgvector-pgvector-848-c2913519959@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-848@github.com>
References: <gh-pgvector-pgvector-848@github.com>
Hi @Joshua-Shin, there aren't any current plans to merge this (as I don't think it's useful for most users, and users who need it can create it with SQL).
```sql
CREATE FUNCTION random_vector(dim integer) RETURNS vector
AS $$ SELECT array_agg(random())::vector FROM generate_series(1, dim) i $$
LANGUAGE SQL;
-- Postgres 16+
CREATE FUNCTION random_normal_vector(dim integer) RETURNS vector
AS $$ SELECT array_agg(random_normal())::vector FROM generate_series(1, dim) i $$
LANGUAGE SQL;
```
```sql
SELECT random_vector(3);
SELECT random_normal_vector(3);
SELECT l2_normalize(random_vector(3));
```