diff --git a/docs/sql-manual/sql-functions/aggregate-functions/regr_intercept.md b/docs/sql-manual/sql-functions/aggregate-functions/regr_intercept.md new file mode 100644 index 0000000000000..e1e9d69bbd378 --- /dev/null +++ b/docs/sql-manual/sql-functions/aggregate-functions/regr_intercept.md @@ -0,0 +1,62 @@ +--- +{ + "title": "REGR_INTERCEPT", + "language": "en" +} +--- + +## Description +REGR_INTERCEPT is used to calculate the y-intercept of the least squares-fit linear equation for a set of number pairs. + +## Syntax +``` +REGR_INTERCEPT(y, x) +``` + +## Parameters +- `y` (Numeric): The dependent variable. +- `x` (Numeric): The independent variable. + +Both `x` and `y` support basic numeric types. + +## Returned values +Returned data type: FLOAT64 + +The function returns the y-intercept of the linear regression line. + +If there are no rows, or only rows with null values, the function returns NULL. + +## Examples +```sql +-- Example 1: Basic Usage +SELECT regr_intercept(y, x) FROM test; + +-- Example 2: Usage in a query with sample data +SELECT * FROM test; ++------+------+------+ +| id | x | y | ++------+------+------+ +| 1 | 18 | 13 | +| 3 | 12 | 2 | +| 5 | 10 | 20 | +| 2 | 14 | 27 | +| 4 | 5 | 6 | ++------+------+------+ + +SELECT regr_intercept(y, x) FROM test; ++----------------------+ +| regr_intercept(y, x) | ++----------------------+ +| 5.512931034482759 | ++----------------------+ +``` + +## Usage notes +- This function ignores any pair where either value is null. +- In cases where the calculation would result in a division by zero, the function will return NULL. + +## Related functions +REGR_SLOPE, REGR_R2, REGR_COUNT, REGR_AVGX, REGR_AVGY + +## References +For more details about linear regression functions, please refer to the SQL standard documentation on aggregate functions. diff --git a/docs/sql-manual/sql-functions/aggregate-functions/regr_slope.md b/docs/sql-manual/sql-functions/aggregate-functions/regr_slope.md new file mode 100644 index 0000000000000..85a090be310de --- /dev/null +++ b/docs/sql-manual/sql-functions/aggregate-functions/regr_slope.md @@ -0,0 +1,62 @@ +--- +{ + "title": "REGR_SLOPE", + "language": "en" +} +--- + +## Description +REGR_SLOPE is used to calculate the slope of the least squares-fit linear equation for a set of number pairs. + +## Syntax +``` +REGR_SLOPE(y, x) +``` + +## Parameters +- `y` (Numeric): The dependent variable. +- `x` (Numeric): The independent variable. + +Both `x` and `y` support basic numeric types. + +## Returned values +Returned data type: FLOAT64 + +The function returns the slope of the linear regression line. + +If there are no rows, or only rows with null values, the function returns NULL. + +## Examples +```sql +-- Example 1: Basic Usage +SELECT regr_slope(y, x) FROM test; + +-- Example 2: Usage in a query with sample data +SELECT * FROM test; ++------+------+------+ +| id | x | y | ++------+------+------+ +| 1 | 18 | 13 | +| 3 | 12 | 2 | +| 5 | 10 | 20 | +| 2 | 14 | 27 | +| 4 | 5 | 6 | ++------+------+------+ + +SELECT regr_slope(y, x) FROM test; ++--------------------+ +| regr_slope(y, x) | ++--------------------+ +| 0.6853448275862069 | ++--------------------+ +``` + +## Usage notes +- This function ignores any pair where either value is null. +- In cases where the calculation would result in a division by zero, the function will return NULL. + +## Related functions +REGR_INTERCEPT, REGR_R2, REGR_COUNT, REGR_AVGX, REGR_AVGY + +## References +For more details about linear regression functions, please refer to the SQL standard documentation on aggregate functions. diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/regr_intercept.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/regr_intercept.md new file mode 100644 index 0000000000000..a619daac246f1 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/regr_intercept.md @@ -0,0 +1,62 @@ +--- +{ + "title": "REGR_INTERCEPT", + "language": "zh-CN" +} +--- + +## Description +REGR_INTERCEPT 用于计算一组数值对的最小二乘拟合线性方程的截距。 + +## Syntax +``` +REGR_INTERCEPT(y, x) +``` + +## Parameters +- `y` (数值类型):因变量。 +- `x` (数值类型):自变量。 + +x 和 y 都支持基本数值类型。 + +## Returned values +返回数据类型:FLOAT64 + +函数返回线性回归直线的截距。 + +如果没有行,或者只有包含空值的行,函数返回 NULL。 + +## Examples +```sql +-- 示例 1:基本用法 +SELECT regr_intercept(y, x) FROM test; + +-- 示例 2:在查询中使用示例数据 +SELECT * FROM test; ++------+------+------+ +| id | x | y | ++------+------+------+ +| 1 | 18 | 13 | +| 3 | 12 | 2 | +| 5 | 10 | 20 | +| 2 | 14 | 27 | +| 4 | 5 | 6 | ++------+------+------+ + +SELECT regr_intercept(y, x) FROM test; ++----------------------+ +| regr_intercept(y, x) | ++----------------------+ +| 5.512931034482759 | ++----------------------+ +``` + +## Usage notes +- 此函数会忽略任何包含空值的数值对。 +- 在计算结果会导致除以零的情况下,函数将返回 NULL。 + +## Related functions +REGR_SLOPE, REGR_R2, REGR_COUNT, REGR_AVGX, REGR_AVGY + +## References +有关线性回归函数的更多详细信息,请参阅 SQL 标准文档中关于聚合函数的部分。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/regr_slope.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/regr_slope.md new file mode 100644 index 0000000000000..295ef814cab4d --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/aggregate-functions/regr_slope.md @@ -0,0 +1,62 @@ +--- +{ + "title": "REGR_SLOPE", + "language": "zh-CN" +} +--- + +## Description +REGR_SLOPE 用于计算一组数值对的最小二乘拟合线性方程的斜率。 + +## Syntax +``` +REGR_SLOPE(y, x) +``` + +## Parameters +- `y` (数值类型):因变量。 +- `x` (数值类型):自变量。 + +x 和 y 都支持基本数值类型。 + +## Returned values +返回数据类型:FLOAT64 + +函数返回线性回归直线的斜率。 + +如果没有行,或者只有包含空值的行,函数返回 NULL。 + +## Examples +```sql +-- 示例 1:基本用法 +SELECT regr_slope(y, x) FROM test; + +-- 示例 2:在查询中使用示例数据 +SELECT * FROM test; ++------+------+------+ +| id | x | y | ++------+------+------+ +| 1 | 18 | 13 | +| 3 | 12 | 2 | +| 5 | 10 | 20 | +| 2 | 14 | 27 | +| 4 | 5 | 6 | ++------+------+------+ + +SELECT regr_slope(y, x) FROM test; ++--------------------+ +| regr_slope(y, x) | ++--------------------+ +| 0.6853448275862069 | ++--------------------+ +``` + +## Usage notes +- 此函数会忽略任何包含空值的数值对。 +- 在计算结果会导致除以零的情况下,函数将返回 NULL。 + +## Related functions +REGR_INTERCEPT, REGR_R2, REGR_COUNT, REGR_AVGX, REGR_AVGY + +## References +有关线性回归函数的更多详细信息,请参阅 SQL 标准文档中关于聚合函数的部分。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/regr_intercept.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/regr_intercept.md new file mode 100644 index 0000000000000..a619daac246f1 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/regr_intercept.md @@ -0,0 +1,62 @@ +--- +{ + "title": "REGR_INTERCEPT", + "language": "zh-CN" +} +--- + +## Description +REGR_INTERCEPT 用于计算一组数值对的最小二乘拟合线性方程的截距。 + +## Syntax +``` +REGR_INTERCEPT(y, x) +``` + +## Parameters +- `y` (数值类型):因变量。 +- `x` (数值类型):自变量。 + +x 和 y 都支持基本数值类型。 + +## Returned values +返回数据类型:FLOAT64 + +函数返回线性回归直线的截距。 + +如果没有行,或者只有包含空值的行,函数返回 NULL。 + +## Examples +```sql +-- 示例 1:基本用法 +SELECT regr_intercept(y, x) FROM test; + +-- 示例 2:在查询中使用示例数据 +SELECT * FROM test; ++------+------+------+ +| id | x | y | ++------+------+------+ +| 1 | 18 | 13 | +| 3 | 12 | 2 | +| 5 | 10 | 20 | +| 2 | 14 | 27 | +| 4 | 5 | 6 | ++------+------+------+ + +SELECT regr_intercept(y, x) FROM test; ++----------------------+ +| regr_intercept(y, x) | ++----------------------+ +| 5.512931034482759 | ++----------------------+ +``` + +## Usage notes +- 此函数会忽略任何包含空值的数值对。 +- 在计算结果会导致除以零的情况下,函数将返回 NULL。 + +## Related functions +REGR_SLOPE, REGR_R2, REGR_COUNT, REGR_AVGX, REGR_AVGY + +## References +有关线性回归函数的更多详细信息,请参阅 SQL 标准文档中关于聚合函数的部分。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/regr_slope.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/regr_slope.md new file mode 100644 index 0000000000000..295ef814cab4d --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-functions/aggregate-functions/regr_slope.md @@ -0,0 +1,62 @@ +--- +{ + "title": "REGR_SLOPE", + "language": "zh-CN" +} +--- + +## Description +REGR_SLOPE 用于计算一组数值对的最小二乘拟合线性方程的斜率。 + +## Syntax +``` +REGR_SLOPE(y, x) +``` + +## Parameters +- `y` (数值类型):因变量。 +- `x` (数值类型):自变量。 + +x 和 y 都支持基本数值类型。 + +## Returned values +返回数据类型:FLOAT64 + +函数返回线性回归直线的斜率。 + +如果没有行,或者只有包含空值的行,函数返回 NULL。 + +## Examples +```sql +-- 示例 1:基本用法 +SELECT regr_slope(y, x) FROM test; + +-- 示例 2:在查询中使用示例数据 +SELECT * FROM test; ++------+------+------+ +| id | x | y | ++------+------+------+ +| 1 | 18 | 13 | +| 3 | 12 | 2 | +| 5 | 10 | 20 | +| 2 | 14 | 27 | +| 4 | 5 | 6 | ++------+------+------+ + +SELECT regr_slope(y, x) FROM test; ++--------------------+ +| regr_slope(y, x) | ++--------------------+ +| 0.6853448275862069 | ++--------------------+ +``` + +## Usage notes +- 此函数会忽略任何包含空值的数值对。 +- 在计算结果会导致除以零的情况下,函数将返回 NULL。 + +## Related functions +REGR_INTERCEPT, REGR_R2, REGR_COUNT, REGR_AVGX, REGR_AVGY + +## References +有关线性回归函数的更多详细信息,请参阅 SQL 标准文档中关于聚合函数的部分。 diff --git a/sidebars.json b/sidebars.json index fc9c9711ae583..a0486494d532e 100644 --- a/sidebars.json +++ b/sidebars.json @@ -1009,6 +1009,8 @@ "sql-manual/sql-functions/aggregate-functions/collect-set", "sql-manual/sql-functions/aggregate-functions/collect-list", "sql-manual/sql-functions/aggregate-functions/retention", + "sql-manual/sql-functions/aggregate-functions/regr_intercept", + "sql-manual/sql-functions/aggregate-functions/regr_slope", "sql-manual/sql-functions/aggregate-functions/regr_sxx", "sql-manual/sql-functions/aggregate-functions/regr_sxy", "sql-manual/sql-functions/aggregate-functions/regr_syy", diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/regr_intercept.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/regr_intercept.md new file mode 100644 index 0000000000000..e1e9d69bbd378 --- /dev/null +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/regr_intercept.md @@ -0,0 +1,62 @@ +--- +{ + "title": "REGR_INTERCEPT", + "language": "en" +} +--- + +## Description +REGR_INTERCEPT is used to calculate the y-intercept of the least squares-fit linear equation for a set of number pairs. + +## Syntax +``` +REGR_INTERCEPT(y, x) +``` + +## Parameters +- `y` (Numeric): The dependent variable. +- `x` (Numeric): The independent variable. + +Both `x` and `y` support basic numeric types. + +## Returned values +Returned data type: FLOAT64 + +The function returns the y-intercept of the linear regression line. + +If there are no rows, or only rows with null values, the function returns NULL. + +## Examples +```sql +-- Example 1: Basic Usage +SELECT regr_intercept(y, x) FROM test; + +-- Example 2: Usage in a query with sample data +SELECT * FROM test; ++------+------+------+ +| id | x | y | ++------+------+------+ +| 1 | 18 | 13 | +| 3 | 12 | 2 | +| 5 | 10 | 20 | +| 2 | 14 | 27 | +| 4 | 5 | 6 | ++------+------+------+ + +SELECT regr_intercept(y, x) FROM test; ++----------------------+ +| regr_intercept(y, x) | ++----------------------+ +| 5.512931034482759 | ++----------------------+ +``` + +## Usage notes +- This function ignores any pair where either value is null. +- In cases where the calculation would result in a division by zero, the function will return NULL. + +## Related functions +REGR_SLOPE, REGR_R2, REGR_COUNT, REGR_AVGX, REGR_AVGY + +## References +For more details about linear regression functions, please refer to the SQL standard documentation on aggregate functions. diff --git a/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/regr_slope.md b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/regr_slope.md new file mode 100644 index 0000000000000..85a090be310de --- /dev/null +++ b/versioned_docs/version-3.0/sql-manual/sql-functions/aggregate-functions/regr_slope.md @@ -0,0 +1,62 @@ +--- +{ + "title": "REGR_SLOPE", + "language": "en" +} +--- + +## Description +REGR_SLOPE is used to calculate the slope of the least squares-fit linear equation for a set of number pairs. + +## Syntax +``` +REGR_SLOPE(y, x) +``` + +## Parameters +- `y` (Numeric): The dependent variable. +- `x` (Numeric): The independent variable. + +Both `x` and `y` support basic numeric types. + +## Returned values +Returned data type: FLOAT64 + +The function returns the slope of the linear regression line. + +If there are no rows, or only rows with null values, the function returns NULL. + +## Examples +```sql +-- Example 1: Basic Usage +SELECT regr_slope(y, x) FROM test; + +-- Example 2: Usage in a query with sample data +SELECT * FROM test; ++------+------+------+ +| id | x | y | ++------+------+------+ +| 1 | 18 | 13 | +| 3 | 12 | 2 | +| 5 | 10 | 20 | +| 2 | 14 | 27 | +| 4 | 5 | 6 | ++------+------+------+ + +SELECT regr_slope(y, x) FROM test; ++--------------------+ +| regr_slope(y, x) | ++--------------------+ +| 0.6853448275862069 | ++--------------------+ +``` + +## Usage notes +- This function ignores any pair where either value is null. +- In cases where the calculation would result in a division by zero, the function will return NULL. + +## Related functions +REGR_INTERCEPT, REGR_R2, REGR_COUNT, REGR_AVGX, REGR_AVGY + +## References +For more details about linear regression functions, please refer to the SQL standard documentation on aggregate functions. diff --git a/versioned_sidebars/version-3.0-sidebars.json b/versioned_sidebars/version-3.0-sidebars.json index d7a7efcfcacb2..18446dddf1667 100644 --- a/versioned_sidebars/version-3.0-sidebars.json +++ b/versioned_sidebars/version-3.0-sidebars.json @@ -999,6 +999,8 @@ "sql-manual/sql-functions/aggregate-functions/collect-set", "sql-manual/sql-functions/aggregate-functions/collect-list", "sql-manual/sql-functions/aggregate-functions/retention", + "sql-manual/sql-functions/aggregate-functions/regr_intercept", + "sql-manual/sql-functions/aggregate-functions/regr_slope", "sql-manual/sql-functions/aggregate-functions/regr_sxx", "sql-manual/sql-functions/aggregate-functions/regr_sxy", "sql-manual/sql-functions/aggregate-functions/regr_syy",