Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions docs/sql-manual/sql-functions/aggregate-functions/stddev-samp.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@

Returns the sample standard deviation of the expr expression

The calculation formula is:

$
\mathrm{STDDEV\_SAMP}(x)=\sqrt{\mathrm{VAR\_SAMP}(x)}=\sqrt{\frac{\sum_{i=1}^{n}(x_i-\bar{x})^2}{n-1}}
$

Where `n` is the number of valid values in the group.

## Syntax

```sql
Expand All @@ -25,11 +33,11 @@ STDDEV_SAMP(<expr>)
## Return Value

Return the sample standard deviation of the expr expression as Double type.
If there is no valid data in the group, returns NULL.
If there is no valid data in the group, returns NULL. If the number of valid values in the group is 1, returns NaN.

### Examples
```sql
-- Create sample tables
-- Create sample table
CREATE TABLE score_table (
student_id INT,
score DOUBLE
Expand Down Expand Up @@ -58,3 +66,24 @@ FROM score_table;
| 4.949747468305831 |
+-------------------+
```

When the number of valid values is 1, `STDDEV_SAMP` returns `NaN`.

```sql
-- Create a single-column sample table
CREATE TABLE sample_values (
value INT
) DISTRIBUTED BY HASH(value)
PROPERTIES (
"replication_num" = "1"
);

INSERT INTO sample_values VALUES (10);

SELECT STDDEV_SAMP(value) AS sample_stddev FROM sample_values;
+---------------+
| sample_stddev |
+---------------+
| NaN |
+---------------+
```
31 changes: 30 additions & 1 deletion docs/sql-manual/sql-functions/aggregate-functions/var-samp.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@

The VAR_SAMP function calculates the sample variance of a specified expression. Unlike VARIANCE (population variance), VAR_SAMP uses n-1 as the divisor, which is considered an unbiased estimate of the population variance in statistics.

The calculation formula is:

$
\mathrm{VAR\_SAMP}(x)=\frac{\sum_{i=1}^{n}(x_i-\bar{x})^2}{n-1}
$

Where `n` is the number of valid values in the group.

## Alias

- VARIANCE_SAMP
Expand All @@ -28,7 +36,7 @@ VAR_SAMP(<expr>)

## Return Value
Returns a Double value representing the calculated sample variance.
If there is no valid data in the group, returns NULL.
If there is no valid data in the group, returns NULL. If the number of valid values in the group is 1, returns NaN.

## Examples
```sql
Expand Down Expand Up @@ -66,3 +74,24 @@ FROM student_scores;
| 29.4107142857143 | 25.73437500000001 |
+------------------+---------------------+
```

When the number of valid values is 1, `VAR_SAMP` returns `NaN`.

```sql
-- Create a single-column sample table
CREATE TABLE sample_values (
value INT
) DISTRIBUTED BY HASH(value)
PROPERTIES (
"replication_num" = "1"
);

INSERT INTO sample_values VALUES (10);

SELECT VAR_SAMP(value) AS sample_variance FROM sample_values;
+-----------------+
| sample_variance |
+-----------------+
| NaN |
+-----------------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@

返回 expr 表达式的样本标准差

计算公式如下:

$
\mathrm{STDDEV\_SAMP}(x)=\sqrt{\mathrm{VAR\_SAMP}(x)}=\sqrt{\frac{\sum_{i=1}^{n}(x_i-\bar{x})^2}{n-1}}
$

其中 `n` 为组内合法数据的个数。

## 语法

```sql
Expand All @@ -25,7 +33,7 @@ STDDEV_SAMP(<expr>)
## 返回值

返回 Double 类型的参数 expr 的样本标准差。
当组内没有合法数据时,返回 NULL。
当组内没有合法数据时,返回 NULL。组内合法数据个数为 1 时,返回 NaN。

## 举例
```sql
Expand Down Expand Up @@ -58,3 +66,24 @@ FROM score_table;
| 4.949747468305831 |
+-------------------+
```

当合法数据个数为 1 时,`STDDEV_SAMP` 返回 `NaN`。

```sql
-- 创建单列示例表
CREATE TABLE sample_values (
value INT
) DISTRIBUTED BY HASH(value)
PROPERTIES (
"replication_num" = "1"
);

INSERT INTO sample_values VALUES (10);

SELECT STDDEV_SAMP(value) AS sample_stddev FROM sample_values;
+---------------+
| sample_stddev |
+---------------+
| NaN |
+---------------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@

VAR_SAMP 函数计算指定表达式的样本方差。与 VARIANCE(总体方差)不同,VAR_SAMP 使用 n-1 作为除数,这在统计学上被认为是对总体方差的无偏估计。

计算公式如下:

$
\mathrm{VAR\_SAMP}(x)=\frac{\sum_{i=1}^{n}(x_i-\bar{x})^2}{n-1}
$

其中 `n` 为组内合法数据的个数。

## 别名

- VARIANCE_SAMP
Expand All @@ -28,7 +36,7 @@ VAR_SAMP(<expr>)

## 返回值
返回一个 Double 类型的值,表示计算得到的样本方差。
组内没有合法数据时,返回 NULL。
组内没有合法数据时,返回 NULL。组内合法数据个数为 1 时,返回 NaN。

## 举例
```sql
Expand Down Expand Up @@ -66,3 +74,24 @@ FROM student_scores;
| 29.4107142857143 | 25.73437500000001 |
+------------------+---------------------+
```

当合法数据个数为 1 时,`VAR_SAMP` 返回 `NaN`。

```sql
-- 创建单列示例表
CREATE TABLE sample_values (
value INT
) DISTRIBUTED BY HASH(value)
PROPERTIES (
"replication_num" = "1"
);

INSERT INTO sample_values VALUES (10);

SELECT VAR_SAMP(value) AS sample_variance FROM sample_values;
+-----------------+
| sample_variance |
+-----------------+
| NaN |
+-----------------+
```
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---

Check warning on line 1 in i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/stddev-samp.md

View workflow job for this annotation

GitHub Actions / Build Check

seo-title-duplicate

Rendered SEO title is duplicated across indexable pages%3A "STDDEV_SAMP - Apache Doris". Add a version%2C locale%2C or page-specific qualifier. Owner%3A @zclllyybb

Check warning on line 1 in i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/aggregate-functions/stddev-samp.md

View workflow job for this annotation

GitHub Actions / Build Check

seo-description-length

SEO description should be 80-160 characters; current length is 17. Owner%3A @zclllyybb
{
"title": "STDDEV_SAMP",
"language": "zh-CN",
Expand All @@ -10,6 +10,14 @@

返回 expr 表达式的样本标准差

计算公式如下:

$
\mathrm{STDDEV\_SAMP}(x)=\sqrt{\mathrm{VAR\_SAMP}(x)}=\sqrt{\frac{\sum_{i=1}^{n}(x_i-\bar{x})^2}{n-1}}
$

其中 `n` 为组内合法数据的个数。

## 语法

```sql
Expand All @@ -25,7 +33,7 @@
## 返回值

返回 Double 类型的参数 expr 的样本标准差。
当组内没有合法数据时,返回 NULL。
当组内没有合法数据时,返回 NULL。组内合法数据个数为 1 时,返回 NaN。

## 举例
```sql
Expand Down Expand Up @@ -58,3 +66,24 @@
| 4.949747468305831 |
+-------------------+
```

当合法数据个数为 1 时,`STDDEV_SAMP` 返回 `NaN`。

```sql
-- 创建单列示例表
CREATE TABLE sample_values (
value INT
) DISTRIBUTED BY HASH(value)
PROPERTIES (
"replication_num" = "1"
);

INSERT INTO sample_values VALUES (10);

SELECT STDDEV_SAMP(value) AS sample_stddev FROM sample_values;
+---------------+
| sample_stddev |
+---------------+
| NaN |
+---------------+
```
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@

VAR_SAMP 函数计算指定表达式的样本方差。与 VARIANCE(总体方差)不同,VAR_SAMP 使用 n-1 作为除数,这在统计学上被认为是对总体方差的无偏估计。

计算公式如下:

$
\mathrm{VAR\_SAMP}(x)=\frac{\sum_{i=1}^{n}(x_i-\bar{x})^2}{n-1}
$

其中 `n` 为组内合法数据的个数。

## 别名

- VARIANCE_SAMP
Expand All @@ -28,7 +36,7 @@ VAR_SAMP(<expr>)

## 返回值
返回一个 Double 类型的值,表示计算得到的样本方差。
组内没有合法数据时,返回 NULL。
组内没有合法数据时,返回 NULL。组内合法数据个数为 1 时,返回 NaN。

## 举例
```sql
Expand Down Expand Up @@ -66,3 +74,24 @@ FROM student_scores;
| 29.4107142857143 | 25.73437500000001 |
+------------------+---------------------+
```

当合法数据个数为 1 时,`VAR_SAMP` 返回 `NaN`。

```sql
-- 创建单列示例表
CREATE TABLE sample_values (
value INT
) DISTRIBUTED BY HASH(value)
PROPERTIES (
"replication_num" = "1"
);

INSERT INTO sample_values VALUES (10);

SELECT VAR_SAMP(value) AS sample_variance FROM sample_values;
+-----------------+
| sample_variance |
+-----------------+
| NaN |
+-----------------+
```
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---

Check notice on line 1 in versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/stddev-samp.md

View workflow job for this annotation

GitHub Actions / Build Check

i18n-sync-locale-candidate

Japanese docs are report-only. Generate a candidate translation from the changed files and merge it only after human review. Owner%3A @zclllyybb

Check notice on line 1 in versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/stddev-samp.md

View workflow job for this annotation

GitHub Actions / Build Check

i18n-sync-version-candidate

A 3.x counterpart exists. Confirm whether the change is supported in 3.x before leaving it unsynced. Owner%3A @zclllyybb

Check warning on line 1 in versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/stddev-samp.md

View workflow job for this annotation

GitHub Actions / Build Check

seo-title-duplicate

Rendered SEO title is duplicated across indexable pages%3A "STDDEV_SAMP - Apache Doris". Add a version%2C locale%2C or page-specific qualifier. Owner%3A @zclllyybb

Check warning on line 1 in versioned_docs/version-4.x/sql-manual/sql-functions/aggregate-functions/stddev-samp.md

View workflow job for this annotation

GitHub Actions / Build Check

seo-description-length

SEO description should be 80-160 characters; current length is 60. Owner%3A @zclllyybb
{
"title": "STDDEV_SAMP",
"language": "en",
Expand All @@ -10,6 +10,14 @@

Returns the sample standard deviation of the expr expression

The calculation formula is:

$
\mathrm{STDDEV\_SAMP}(x)=\sqrt{\mathrm{VAR\_SAMP}(x)}=\sqrt{\frac{\sum_{i=1}^{n}(x_i-\bar{x})^2}{n-1}}
$

Where `n` is the number of valid values in the group.

## Syntax

```sql
Expand All @@ -25,11 +33,11 @@
## Return Value

Return the sample standard deviation of the expr expression as Double type.
If there is no valid data in the group, returns NULL.
If there is no valid data in the group, returns NULL. If the number of valid values in the group is 1, returns NaN.

### Examples
```sql
-- Create sample tables
-- Create sample table
CREATE TABLE score_table (
student_id INT,
score DOUBLE
Expand Down Expand Up @@ -58,3 +66,24 @@
| 4.949747468305831 |
+-------------------+
```

When the number of valid values is 1, `STDDEV_SAMP` returns `NaN`.

```sql
-- Create a single-column sample table
CREATE TABLE sample_values (
value INT
) DISTRIBUTED BY HASH(value)
PROPERTIES (
"replication_num" = "1"
);

INSERT INTO sample_values VALUES (10);

SELECT STDDEV_SAMP(value) AS sample_stddev FROM sample_values;
+---------------+
| sample_stddev |
+---------------+
| NaN |
+---------------+
```
Loading
Loading