forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Beginning of the stats_agg docs` Still WIP for now, but pushing to begin the process.` * Continuing adding stats_agg API elements * Apply suggestions from code review Co-authored-by: Lana Brindley <github@lanabrindley.com> * Add missing links * Fix tables * Apply suggestions from code review Co-authored-by: Lana Brindley <github@lanabrindley.com> Co-authored-by: Lana Brindley <github@lanabrindley.com>
- Loading branch information
1 parent
84ca585
commit 9c91498
Showing
27 changed files
with
1,084 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# average(), average_y(), and average_x() <tag type="toolkit">Toolkit</tag> | ||
|
||
```SQL | ||
average(summary StatsSummary1D) RETURNS BIGINT | ||
``` | ||
```SQL | ||
average_y(summary StatsSummary2D) RETURNS BIGINT | ||
``` | ||
```SQL | ||
average_x(summary StatsSummary2D) RETURNS BIGINT | ||
``` | ||
|
||
Get the average of the values contained in a statistical aggregate. | ||
In a two-dimensional [`stats_agg`][stats-agg] use the `_y`/ `_x` form to access the | ||
average of the dependent and independent variables. | ||
|
||
For more information about statistical aggregate functions, see the | ||
[hyperfunctions documentation][hyperfunctions-stats-agg]. | ||
|
||
## Required arguments | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|`summary`|`StatsSummary1D`/`StatsSummary2D`|The already constructed data structure from a previous [`stats_agg`][stats-agg] call| | ||
|
||
## Returns | ||
|
||
|Column|Type|Description| | ||
|-|-|-| | ||
|`average`/`average_y`/`average_x`|`DOUBLE PRECISION`|The average of the values in the statistical aggregate| | ||
|
||
## Sample usage | ||
|
||
```SQL | ||
SELECT average(stats_agg(data)) | ||
FROM generate_series(0, 100) data; | ||
``` | ||
```output | ||
average | ||
----------- | ||
50 | ||
``` | ||
|
||
|
||
[hyperfunctions-stats-agg]: timescaledb/:currentVersion:/how-to-guides/hyperfunctions/stats-aggs/ | ||
[stats-agg]:/hyperfunctions/stats_aggs/stats_agg/ |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# corr() <tag type="toolkit" content="toolkit" /> | ||
|
||
```sql | ||
corr( | ||
summary StatsSummary2D | ||
) RETURNS DOUBLE PRECISION | ||
``` | ||
The correlation coefficient of the [least squares fit][least-squares] line | ||
computed from a two-dimensional statistical aggregate. | ||
|
||
For more information about statistical aggregate functions, see the | ||
[hyperfunctions documentation][hyperfunctions-stats-agg]. | ||
|
||
## Required arguments | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|`summary`|`StatsSummary2D`|The input StatsSummary from a [`stats_agg` call][stats-agg]| | ||
|
||
## Returns | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|`corr`|`DOUBLE PRECISION`|The correlation coefficient of the least squares fit line.| | ||
|
||
## Sample usage | ||
|
||
```sql | ||
SELECT | ||
id, | ||
time_bucket('15 min'::interval, ts) AS bucket, | ||
corr(stats_agg(y, x)) AS summary | ||
FROM foo | ||
GROUP BY id, time_bucket('15 min'::interval, ts) | ||
``` | ||
|
||
|
||
[hyperfunctions-stats-agg]: timescaledb/:currentVersion:/how-to-guides/hyperfunctions/stats-aggs/ | ||
[stats-agg]:/hyperfunctions/stats_aggs/stats_agg/ | ||
[least-squares]:https://en.wikipedia.org/wiki/Least_squares |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# covariance() <tag type="toolkit" content="toolkit" /> | ||
|
||
```sql | ||
covariance( | ||
summary StatsSummary2D, | ||
method TEXT | ||
) RETURNS DOUBLE PRECISION | ||
``` | ||
The covariance of the [least squares fit][least-squares] line | ||
computed from a two-dimensional statistical aggregate. | ||
|
||
The `method` determines whether you calculate a 'population' or 'sample' covariance. | ||
These values can be provided as their full names, or you can abbreviate them as `pop` or `samp`. These | ||
are the only four accepted values for the `method` argument. The default is `sample`. | ||
|
||
For more information about statistical aggregate functions, see the | ||
[hyperfunctions documentation][hyperfunctions-stats-agg]. | ||
|
||
## Required arguments | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|`summary`|`StatsSummary2D`|The input StatsSummary from a [`stats_agg` call][stats-agg]| | ||
|
||
### Optional Arguments | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|`method`|`TEXT`|The method for the calculation 'population' or 'sample' (default)| | ||
|
||
## Returns | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|`covariance`|`DOUBLE PRECISION`|The x intercept of the least squares fit line.| | ||
|
||
## Sample usage | ||
|
||
```sql | ||
SELECT | ||
id, | ||
time_bucket('15 min'::interval, ts) AS bucket, | ||
covariance(stats_agg(y, x)) AS summary | ||
FROM foo | ||
GROUP BY id, time_bucket('15 min'::interval, ts) | ||
``` | ||
|
||
|
||
[hyperfunctions-stats-agg]: timescaledb/:currentVersion:/how-to-guides/hyperfunctions/stats-aggs/ | ||
[stats-agg]:/hyperfunctions/stats_aggs/stats_agg/ | ||
[least-squares]:https://en.wikipedia.org/wiki/Least_squares |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# determination_coeff() <tag type="toolkit" content="toolkit" /> | ||
|
||
```sql | ||
determination_coeff( | ||
summary StatsSummary2D | ||
) RETURNS DOUBLE PRECISION | ||
``` | ||
The coefficient of determination (or the R squared) of the least squares fit line | ||
computed from a two-dimensional statistical aggregate. | ||
|
||
For more information about statistical aggregate functions, see the | ||
[hyperfunctions documentation][hyperfunctions-stats-agg]. | ||
|
||
## Required arguments | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|`summary`|`StatsSummary2D`|The input StatsSummary from a [`stats_agg` call][stats-agg]| | ||
|
||
## Returns | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|`determination_coeff`|`DOUBLE PRECISION`|The determination coefficient of the least squares fit line.| | ||
|
||
## Sample usage | ||
|
||
```sql | ||
SELECT | ||
id, | ||
time_bucket('15 min'::interval, ts) AS bucket, | ||
determination_coeff(stats_agg(y, x)) AS summary | ||
FROM foo | ||
GROUP BY id, time_bucket('15 min'::interval, ts) | ||
``` | ||
|
||
|
||
[hyperfunctions-stats-agg]: timescaledb/:currentVersion:/how-to-guides/hyperfunctions/stats-aggs/ | ||
[stats-agg]:/hyperfunctions/stats_aggs/stats_agg/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# intercept() <tag type="toolkit" content="toolkit" /> | ||
|
||
```sql | ||
intercept( | ||
summary StatsSummary2D | ||
) RETURNS DOUBLE PRECISION | ||
``` | ||
|
||
The y intercept of the [least squares fit][least-squares] line computed | ||
from a two-dimensional statistical aggregate. | ||
|
||
For more information about statistical aggregate functions, see the | ||
[hyperfunctions documentation][hyperfunctions-stats-agg]. | ||
|
||
## Required arguments | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|`summary`|`StatsSummary2D`|The input StatsSummary from a [`stats_agg` call][stats-agg]| | ||
|
||
## Returns | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|`intercept`|`DOUBLE PRECISION`|The y intercept of the least squares fit line.| | ||
|
||
## Sample usage | ||
|
||
```sql | ||
SELECT | ||
id, | ||
time_bucket('15 min'::interval, ts) AS bucket, | ||
intercept(stats_agg(y, x)) AS summary | ||
FROM foo | ||
GROUP BY id, time_bucket('15 min'::interval, ts) | ||
``` | ||
|
||
|
||
[hyperfunctions-stats-agg]: timescaledb/:currentVersion:/how-to-guides/hyperfunctions/stats-aggs/ | ||
[stats-agg]:/hyperfunctions/stats_aggs/stats_agg/ | ||
[least-squares]:https://en.wikipedia.org/wiki/Least_squares |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# kurtosis() / kurtosis_y() / kurtosis_x() <tag type="toolkit">Toolkit</tag> | ||
|
||
```SQL | ||
kurtosis(summary StatsSummary1D, method TEXT) RETURNS BIGINT | ||
``` | ||
```SQL | ||
kurtosis_y(summary StatsSummary2D, method TEXT) RETURNS BIGINT | ||
``` | ||
```SQL | ||
kurtosis_x(summary StatsSummary2D, method TEXT) RETURNS BIGINT | ||
``` | ||
|
||
Calculate the [kurtosis][kurtosis], or the 4th statistical moment, of the values contained | ||
in a statistical aggregate. In a two-dimensional [`stats_agg`][stats-agg] use | ||
the `_y`/ `_x` form to access the `kurtosis` of the dependent and independent variables. | ||
|
||
The `method` determines whether you calculate a population or sample kurtosis. These | ||
values can be provided as their full names, or you can abbreviate them as `pop` or `samp`. | ||
These are the only four accepted values for the `method` argument. The default is `sample`. | ||
|
||
For more information about statistical aggregate functions, see the | ||
[hyperfunctions documentation][hyperfunctions-stats-agg]. | ||
|
||
## Required arguments | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|`summary`|`StatsSummary1D`/`StatsSummary2D`|The already constructed data structure from a previous [`stats_agg`][stats-agg] call| | ||
|
||
### Optional arguments | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|`method`|`TEXT`|The method for the calculation 'population' or 'sample' (default)| | ||
|
||
## Returns | ||
|
||
|Column|Type|Description| | ||
|-|-|-| | ||
|`kurtosis`/`kurtosis_y`/`kurtosis_x`|`DOUBLE PRECISION`|The kurtosis of the values in the statistical aggregate| | ||
|
||
## Sample usage | ||
|
||
```SQL | ||
SELECT kurtosis_y(stats_agg(data, data)) | ||
FROM generate_series(0, 100) data; | ||
``` | ||
```output | ||
kurtosis_y | ||
------------ | ||
1.78195 | ||
``` | ||
|
||
|
||
[hyperfunctions-stats-agg]: timescaledb/:currentVersion:/how-to-guides/hyperfunctions/stats-aggs/ | ||
[stats-agg]:/hyperfunctions/stats_aggs/stats_agg/ | ||
[kurtosis]: https://en.wikipedia.org/wiki/Kurtosis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.