---
title: x_intercept() | Tiger Data Docs
description: Calculate the x-intercept from a two-dimensional statistical aggregate
---

Since [1.3.0](https://github.com/timescale/timescaledb-toolkit/releases/tag/1.3.0)

Calculate the x intercept from a two-dimensional statistical aggregate. The calculation uses the standard least-squares fitting for linear regression.

## Samples

Calculate the x intercept from independent variable `y` and dependent variable `x` for each 15-minute time bucket:

```
SELECT
    id,
    time_bucket('15 min'::interval, ts) AS bucket,
    x_intercept(stats_agg(y, x)) AS summary
FROM foo
GROUP BY id, time_bucket('15 min'::interval, ts)
```

## Arguments

The syntax is:

```
x_intercept(
  summary StatsSummary2D
) RETURNS DOUBLE PRECISION
```

| Name    | Type           | Default | Required | Description                                              |
| ------- | -------------- | ------- | -------- | -------------------------------------------------------- |
| summary | StatsSummary2D | -       | ✔        | The statistical aggregate produced by a `stats_agg` call |

## Returns

| Column    | Type             | Description                                   |
| --------- | ---------------- | --------------------------------------------- |
| intercept | DOUBLE PRECISION | The x intercept of the least-squares fit line |
