> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> データセットの標本分散を計算します。`varSamp` とは異なり、この関数では数値的に安定したアルゴリズムを使用します。処理速度は遅くなりますが、計算誤差をより小さく抑えられます。

# varSampStable

<h2 id="varSampStable">
  varSampStable
</h2>

導入バージョン: v1.1.0

データセットの標本分散を計算します。[`varSamp`](/reference/functions/aggregate-functions/varSamp) とは異なり、この関数は[数値的に安定した](https://en.wikipedia.org/wiki/Numerical_stability)アルゴリズムを使用します。処理速度は遅くなりますが、計算誤差が小さくなります。

標本分散は [`varSamp`](/reference/functions/aggregate-functions/varSamp) と同じ式で計算されます：

$$
\frac{\Sigma{(x - \bar{x})^2}}{n-1}
$$

<br />

ここで：

* $x$ はデータセット内の各データポイント
* $\bar{x}$ はデータセットの算術平均
* $n$ はデータセット内のデータポイント数

**Syntax**

```sql theme={null}
varSampStable(x)
```

**引数**

* `x` — 標本分散を計算する対象の母集団。[`(U)Int*`](/reference/data-types/int-uint) または [`Float*`](/reference/data-types/float) または [`Decimal*`](/reference/data-types/decimal)

**戻り値**

入力データセットの標本分散を返します。[`Float64`](/reference/data-types/float)

**例**

**安定した標本分散の計算**

```sql title=Query theme={null}
DROP TABLE IF EXISTS test_data;
CREATE TABLE test_data
(
    x Float64
)
ENGINE = Memory;

INSERT INTO test_data VALUES (10.5), (12.3), (9.8), (11.2), (10.7);

SELECT round(varSampStable(x),3) AS var_samp_stable FROM test_data;
```

```response title=Response theme={null}
┌─var_samp_stable─┐
│           0.865 │
└─────────────────┘
```
