From: | Shaozhong SHI <shishaozhong(at)gmail(dot)com> |
---|---|
To: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
Cc: | Pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: frequency of positive and negative numbers, sizes of numbers and frequency of alteration of polarity |
Date: | 2022-02-17 21:42:20 |
Message-ID: | CA+i5JwbXkmm2tZQe2zfrrLrCMNX1twSG6fTvkvi7iQVQtQ8ikw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, 17 Feb 2022 at 21:20, Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> On Fri, Feb 18, 2022 at 9:11 AM Shaozhong SHI <shishaozhong(at)gmail(dot)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)
>
Given 2 or more such columns, is there any measure that can be calculated
to tell which one alternates more than others?
Regards,
David
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Munro | 2022-02-17 21:55:49 | Re: frequency of positive and negative numbers, sizes of numbers and frequency of alteration of polarity |
Previous Message | Shaozhong SHI | 2022-02-17 21:35:17 | Re: frequency of positive and negative numbers, sizes of numbers and frequency of alteration of polarity |