Help needed structuring Postgresql correlation query

Поиск
Список
Период
Сортировка
От Tim Smith
Тема Help needed structuring Postgresql correlation query
Дата
Msg-id CA+HuS5HxYeXNuWnpXuBbu8xtFR0KvqkAvqq_SVVz0UapTjZutQ@mail.gmail.com
обсуждение исходный текст
Ответы Re: Help needed structuring Postgresql correlation query  (Alban Hertroys <haramrae@gmail.com>)
Список pgsql-general
Hi,

My postgresql-fu is not good enough to write a query to achieve this
(some may well say r is a better suited tool to achieve this !).

I need to calculate what I would call a correlation window on a time
series of data, my table looks like this :

create table data(data_date date,data_measurement numeric);
insert into data values('2016-01-01',16.23);
<etc>
insert into data values('2016-06-19',30.54);

My "target sample" would be the N most recent samples in the table
(e.g. 20, the most recent 20 days)

My "potential sample" would be a moving window of size N (the same
size N as above), starting at T0 (i.e. 2016-01-01 in this example) and
incrementing by one (i.e. 2016-01-01 + 20, then 2016-01-02+20 etc),
but the "target sample" would obviously be excluded.

The output needs to display window date range (or at least the start
date of the "potential sample" window) and the result
corr(target,potential).

Hope that makes sense

Tim


В списке pgsql-general по дате отправления:

Предыдущее
От: "Erdmann, Markus @ Bellevue"
Дата:
Сообщение: Re: Regression in query optimizer when upgrading from 9.4.5 to 9.5.2?
Следующее
От: Allan Kamau
Дата:
Сообщение: Help with namespaces in xpath (PostgreSQL 9.5.3)