> ## 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.

> 返回时间序列在时间点 `t` 的值的经指数平滑处理的加权移动平均值。

# exponentialTimeDecayedAvg

<div id="exponentialTimeDecayedAvg">
  ## exponentialTimeDecayedAvg
</div>

引入版本：v21.12.0

返回时间序列在时间点 `t` 的值经指数平滑后的加权移动平均值。

**语法**

```sql theme={null}
exponentialTimeDecayedAvg(x)(v, t)
```

**参数**

* `x` — 半衰期。[`(U)Int*`](/zh/reference/data-types/int-uint) 或 [`Float*`](/zh/reference/data-types/float) 或 [`Decimal`](/zh/reference/data-types/decimal)

**参数**

* `v` — 值。[`(U)Int*`](/zh/reference/data-types/int-uint) 或 [`Float*`](/zh/reference/data-types/float) 或 [`Decimal`](/zh/reference/data-types/decimal)
* `t` — 时间。[`(U)Int*`](/zh/reference/data-types/int-uint) 或 [`Float*`](/zh/reference/data-types/float) 或 [`Decimal`](/zh/reference/data-types/decimal) 或 [`DateTime`](/zh/reference/data-types/datetime) 或 [`DateTime64`](/zh/reference/data-types/datetime64)

**返回值**

返回时间索引 `t` 处经指数平滑加权后的移动平均值。[`Float64`](/zh/reference/data-types/float)

**示例**

**带可视化展示的窗口函数用法**

```sql title=Query theme={null}
SELECT
    value,
    time,
    round(exp_smooth, 3),
    bar(exp_smooth, 0, 5, 50) AS bar
FROM
    (
    SELECT
    (number = 0) OR (number >= 25) AS value,
    number AS time,
    exponentialTimeDecayedAvg(10)(value, time) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS exp_smooth
    FROM numbers(50)
    )
```

```response title=Response theme={null}
┌─value─┬─time─┬─round(exp_smooth, 3)─┬─bar────────┐
│     1 │    0 │                    1 │ ██████████ │
│     0 │    1 │                0.475 │ ████▊      │
│     0 │    2 │                0.301 │ ███        │
│     0 │    3 │                0.214 │ ██▏        │
│     0 │    4 │                0.162 │ █▌         │
│     0 │    5 │                0.128 │ █▎         │
│     0 │    6 │                0.104 │ █          │
│     0 │    7 │                0.086 │ ▊          │
│     0 │    8 │                0.072 │ ▋          │
│     0 │    9 │                0.061 │ ▌          │
│     0 │   10 │                0.052 │ ▌          │
│     0 │   11 │                0.045 │ ▍          │
│     0 │   12 │                0.039 │ ▍          │
│     0 │   13 │                0.034 │ ▎          │
│     0 │   14 │                 0.03 │ ▎          │
│     0 │   15 │                0.027 │ ▎          │
│     0 │   16 │                0.024 │ ▏          │
│     0 │   17 │                0.021 │ ▏          │
│     0 │   18 │                0.018 │ ▏          │
│     0 │   19 │                0.016 │ ▏          │
│     0 │   20 │                0.015 │ ▏          │
│     0 │   21 │                0.013 │ ▏          │
│     0 │   22 │                0.012 │            │
│     0 │   23 │                 0.01 │            │
│     0 │   24 │                0.009 │            │
│     1 │   25 │                0.111 │ █          │
│     1 │   26 │                0.202 │ ██         │
│     1 │   27 │                0.283 │ ██▊        │
│     1 │   28 │                0.355 │ ███▌       │
│     1 │   29 │                 0.42 │ ████▏      │
│     1 │   30 │                0.477 │ ████▊      │
│     1 │   31 │                0.529 │ █████▎     │
│     1 │   32 │                0.576 │ █████▊     │
│     1 │   33 │                0.618 │ ██████▏    │
│     1 │   34 │                0.655 │ ██████▌    │
│     1 │   35 │                0.689 │ ██████▉    │
│     1 │   36 │                0.719 │ ███████▏   │
│     1 │   37 │                0.747 │ ███████▍   │
│     1 │   38 │                0.771 │ ███████▋   │
│     1 │   39 │                0.793 │ ███████▉   │
│     1 │   40 │                0.813 │ ████████▏  │
│     1 │   41 │                0.831 │ ████████▎  │
│     1 │   42 │                0.848 │ ████████▍  │
│     1 │   43 │                0.862 │ ████████▌  │
│     1 │   44 │                0.876 │ ████████▊  │
│     1 │   45 │                0.888 │ ████████▉  │
│     1 │   46 │                0.898 │ ████████▉  │
│     1 │   47 │                0.908 │ █████████  │
│     1 │   48 │                0.917 │ █████████▏ │
│     1 │   49 │                0.925 │ █████████▏ │
└───────┴──────┴──────────────────────┴────────────┘
```
