Re: frequency of positive and negative numbers, sizes of numbers and frequency of alteration of polarity

Поиск
Список
Период
Сортировка
От Thomas Munro
Тема Re: frequency of positive and negative numbers, sizes of numbers and frequency of alteration of polarity
Дата
Msg-id CA+hUKGKak-2upw96+gvGrt7w9_fyHQ4U-X0fu-txKomRmeGB0A@mail.gmail.com
обсуждение исходный текст
Ответ на frequency of positive and negative numbers, sizes of numbers and frequency of alteration of polarity  (Shaozhong SHI <shishaozhong@gmail.com>)
Ответы Re: frequency of positive and negative numbers, sizes of numbers and frequency of alteration of polarity  (Shaozhong SHI <shishaozhong@gmail.com>)
Re: frequency of positive and negative numbers, sizes of numbers and frequency of alteration of polarity  (Shaozhong SHI <shishaozhong@gmail.com>)
Список pgsql-general
On Fri, Feb 18, 2022 at 9:11 AM Shaozhong SHI <shishaozhong@gmail.com> wrote:
> How to calculate frequency of positive and negative numbers and define and calculate frequency of alteration of
polarity?
>
> Surely, we can use frequency of alteration of polarity and level of change (e.g., size of positive and negative
numbers)to measure degree and frequency of alteration.
 
>
> Any ideas in doing so in postgres tables' columns full of positive and negative numbers?

Window functions might be useful to detect polarity changes:

postgres=# create table time_series (time int, value int);
CREATE TABLE
postgres=# insert into time_series values (1, -5), (2, -5), (3, 10), (4, -3);
INSERT 0 4
postgres=# select time,
                  value,
                  sign(lag(value) over (order by time)) != sign(value)
as flipped
             from time_series;
 time | value | flipped
------+-------+---------
    1 |    -5 |
    2 |    -5 | f
    3 |    10 | t
    4 |    -3 | t
(4 rows)



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

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: Give default privileges to another SuperUser ?
Следующее
От: Shaozhong SHI
Дата:
Сообщение: Re: frequency of positive and negative numbers, sizes of numbers and frequency of alteration of polarity