> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> احسب تباين العينة لمجموعة البيانات.

# varSamp

<h2 id="varSamp">
  varSamp
</h2>

Introduced in: v1.1.0

احسب تباين العينة لمجموعة بيانات.

يُحسب تباين العينة باستخدام الصيغة:

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

<br />

Where:

* $x$ is each individual data point in the data set
* $\bar{x}$ is the arithmetic mean of the data set
* $n$ is the number of data points in the data set

The function assumes that the input data set represents a sample from a larger population. If you want to calculate the variance of the entire population (when you have the complete data set), you should use [`varPop`](/docs/reference/functions/aggregate-functions/varPop) instead.

<Note>
  تستخدم هذه الدالة خوارزمية غير مستقرة عدديًا. إذا كنت بحاجة إلى [الاستقرار العددي](https://en.wikipedia.org/wiki/Numerical_stability) في الحسابات، فاستخدم الدالة [`varSampStable`](/docs/reference/functions/aggregate-functions/varSampStable). تعمل بصورة أبطأ، لكنها تُقلّل من الخطأ الحسابي.
</Note>

**Syntax**

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

**Aliases**: `VAR_SAMP`

**Arguments**

* `x` — المجتمع الإحصائي الذي تريد حساب تباين العينة له. [`(U)Int*`](/docs/reference/data-types/int-uint) أو [`Float*`](/docs/reference/data-types/float) أو [`Decimal*`](/docs/reference/data-types/decimal)

**القيمة المُعادة**

تُعيد تباين العينة لمجموعة البيانات المُدخلة `x`. [`Float64`](/docs/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(varSamp(x),3) AS var_samp FROM test_data;
```

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