# Chalk SQL Reference: Statistical Functions
source: https://docs.chalk.ai/chalksql-docs#section-statistical-functions

## `beta_cdf(a, b, value)`
source: https://docs.chalk.ai/chalksql-docs#beta_cdf

Compute the Beta cdf with given `a`, `b` parameters: P(N < `value`; `a`, `b`). The `a`, `b` parameters must be positive real numbers and `value` must be `a` real `value` (all of type DOUBLE). The `value` must lie on the interval [0, 1].

**Parameters**

- `a`: `double`
- `b`: `double`
- `value`: `double`
  The input `value`.

## `binomial_cdf(numberOfTrials, successProbability, value)`
source: https://docs.chalk.ai/chalksql-docs#binomial_cdf

Compute the Binomial cdf with given `numberOfTrials` and `successProbability` (for a single trial): P(N < `value`). The `successProbability` must be real `value` in [0, 1], `numberOfTrials` and `value` must be positive integers with `numberOfTrials` greater or equal to `value`.

**Parameters**

- `numberOfTrials`: `int64`
- `successProbability`: `double`
- `value`: `int64`
  The input `value`.

## `cauchy_cdf(median, scale, value)`
source: https://docs.chalk.ai/chalksql-docs#cauchy_cdf

Compute the Cauchy cdf with given parameters `median` and `scale` (gamma): P(N; `median`, `scale`). The `scale` parameter must be a positive double. The `value` parameter must be a double on the interval [0, 1].

**Parameters**

- `median`: `double`
- `scale`: `double`
- `value`: `double`
  The input `value`.

## `chi_squared_cdf(df, value)`
source: https://docs.chalk.ai/chalksql-docs#chi_squared_cdf

Compute the Chi-square cdf with given `df` (degrees of freedom) parameter: P(N < `value`; `df`). The `df` parameter must be a positive real number, and `value` must be a non-negative real `value` (both of type DOUBLE).

**Parameters**

- `df`: `double`
- `value`: `double`
  The input `value`.

## `cpc_sketch_cardinality(sketch)`
source: https://docs.chalk.ai/chalksql-docs#cpc_sketch_cardinality

Reads the estimated distinct count off a CPC `sketch`, rounded to the nearest integer.

**Overloads**

#### `cpc_sketch_cardinality(sketch)`

**Parameters**

- `sketch`: `binary`
  The serialized CPC `sketch`.

#### `cpc_sketch_cardinality(sketch)`

**Parameters**

- `sketch`: `large_binary`
  The serialized CPC `sketch`.

## `cpc_sketch_of(value)`
source: https://docs.chalk.ai/chalksql-docs#cpc_sketch_of

Builds a single-element CPC sketch, sized and seeded to match the sketches produced by approx_count_distinct.

**Overloads**

#### `cpc_sketch_of(value)`

**Parameters**

- `value`: `int8`
  The input `value`.

#### `cpc_sketch_of(value)`

**Parameters**

- `value`: `int16`
  The input `value`.

#### `cpc_sketch_of(value)`

**Parameters**

- `value`: `int32`
  The input `value`.

#### `cpc_sketch_of(value)`

**Parameters**

- `value`: `int64`
  The input `value`.

#### `cpc_sketch_of(value)`

**Parameters**

- `value`: `halffloat`
  The input `value`.

#### `cpc_sketch_of(value)`

**Parameters**

- `value`: `float`
  The input `value`.

#### `cpc_sketch_of(value)`

**Parameters**

- `value`: `double`
  The input `value`.

#### `cpc_sketch_of(value)`

**Parameters**

- `value`: `timestamp[us, tz=UTC]`
  The input `value`.

#### `cpc_sketch_of(value)`

**Parameters**

- `value`: `string`
  The input `value`.

#### `cpc_sketch_of(value)`

**Parameters**

- `value`: `large_string`
  The input `value`.

#### `cpc_sketch_of(value)`

**Parameters**

- `value`: `binary`
  The input `value`.

#### `cpc_sketch_of(value)`

**Parameters**

- `value`: `large_binary`
  The input `value`.

## `cpc_sketch_union(sketch, sketches)`
source: https://docs.chalk.ai/chalksql-docs#cpc_sketch_union

Unions CPC `sketches` into a single `sketch`. Null arguments are skipped; all-null input yields null.

**Overloads**

#### `cpc_sketch_union(sketch, sketches)`

**Parameters**

- `sketch`: `binary`
  The serialized CPC `sketch`.
- `sketches`: `binary...`
  Additional serialized CPC `sketches`.

#### `cpc_sketch_union(sketch, sketches)`

**Parameters**

- `sketch`: `large_binary`
  The serialized CPC `sketch`.
- `sketches`: `large_binary...`
  Additional serialized CPC `sketches`.

## `f_cdf(df1, df2, value)`
source: https://docs.chalk.ai/chalksql-docs#f_cdf

Compute the F cdf with given `df1` (numerator degrees of freedom) and `df2` (denominator degrees of freedom) parameters: P(N < `value`; `df1`, `df2`). The numerator and denominator df parameters must be positive real numbers. The `value` must be a non-negative real number.

**Parameters**

- `df1`: `double`
- `df2`: `double`
- `value`: `double`
  The input `value`.

## `gamma_cdf(shape, scale, value)`
source: https://docs.chalk.ai/chalksql-docs#gamma_cdf

Compute the Gamma cdf with given `shape` and `scale` parameters: P(N < `value`; `shape`, `scale`). The `shape` and `scale` parameters must be positive real numbers. The `value` must be a non-negative real number.

**Parameters**

- `shape`: `double`
- `scale`: `double`
- `value`: `double`
  The input `value`.

## `inverse_beta_cdf(a, b, p)`
source: https://docs.chalk.ai/chalksql-docs#inverse_beta_cdf

Compute the inverse of the Beta cdf with given `a`, `b` parameters for the cumulative probability (`p`): P(N < n). The `a`, `b` parameters must be positive double values. The probability `p` must lie on the interval [0, 1].

**Parameters**

- `a`: `double`
- `b`: `double`
- `p`: `double`

## `inverse_binomial_cdf(numberOfTrials, successProbability, p)`
source: https://docs.chalk.ai/chalksql-docs#inverse_binomial_cdf

Compute the inverse of the Binomial cdf with given `numberOfTrials` and `successProbability` (of a single trial) the cumulative probability (`p`): P(N <= n). The `successProbability` and `p` must be real values in [0, 1] and the `numberOfTrials` must be a positive integer.

**Parameters**

- `numberOfTrials`: `int64`
- `successProbability`: `double`
- `p`: `double`

## `inverse_cauchy_cdf(median, scale, p)`
source: https://docs.chalk.ai/chalksql-docs#inverse_cauchy_cdf

Compute the inverse of the Cauchy cdf with given parameters `median` and `scale` (gamma) for the probability `p`. The `scale` parameter must be a positive double. The probability `p` must be a double on the interval [0, 1].

**Parameters**

- `median`: `double`
- `scale`: `double`
- `p`: `double`

## `inverse_chi_squared_cdf(df, p)`
source: https://docs.chalk.ai/chalksql-docs#inverse_chi_squared_cdf

Compute the inverse of the Chi-square cdf with given `df` (degrees of freedom) parameter for the cumulative probability (`p`): P(N < n). The `df` parameter must be positive real values. The probability `p` must lie on the interval [0, 1].

**Parameters**

- `df`: `double`
- `p`: `double`

## `inverse_f_cdf(df1, df2, p)`
source: https://docs.chalk.ai/chalksql-docs#inverse_f_cdf

Compute the inverse of the Fisher F cdf with a given `df1` (numerator degrees of freedom) and `df2` (denominator degrees of freedom) parameters for the cumulative probability (`p`): P(N < n). The numerator and denominator df parameters must be positive real numbers. The probability `p` must lie on the interval [0, 1].

**Parameters**

- `df1`: `double`
- `df2`: `double`
- `p`: `double`

## `inverse_gamma_cdf(shape, scale, p)`
source: https://docs.chalk.ai/chalksql-docs#inverse_gamma_cdf

Alias for [gamma_cdf](https://docs.chalk.ai/chalksql-docs#gamma_cdf).

## `inverse_laplace_cdf(mean, scale, p)`
source: https://docs.chalk.ai/chalksql-docs#inverse_laplace_cdf

Compute the inverse of the Laplace cdf with given `mean` and `scale` parameters for the cumulative probability (`p`): P(N < n). The `mean` must be a real value and the `scale` must be a positive real value (both of type DOUBLE). The probability `p` must lie on the interval [0, 1].

**Parameters**

- `mean`: `double`
- `scale`: `double`
- `p`: `double`

## `inverse_normal_cdf(mean, sd, p)`
source: https://docs.chalk.ai/chalksql-docs#inverse_normal_cdf

Compute the inverse of the Normal cdf with given `mean` and standard deviation (`sd`) for the cumulative probability (`p`): P(N < n). The `mean` must be a real value and the standard deviation must be a real and positive value (both of type DOUBLE). The probability `p` must lie on the interval (0, 1).

**Parameters**

- `mean`: `double`
- `sd`: `double`
- `p`: `double`

## `inverse_poisson_cdf(lambda, p)`
source: https://docs.chalk.ai/chalksql-docs#inverse_poisson_cdf

Compute the inverse of the Poisson cdf with given `lambda` (mean) parameter for the cumulative probability (`p`). It returns the value of n so that: P(N <= n; `lambda`) = `p`. The `lambda` parameter must be a positive real number (of type DOUBLE). The probability `p` must lie on the interval [0, 1).

**Parameters**

- `lambda`: `double`
- `p`: `double`

## `inverse_weibull_cdf(a, b, p)`
source: https://docs.chalk.ai/chalksql-docs#inverse_weibull_cdf

Compute the inverse of the Weibull cdf with given parameters `a`, `b` for the probability `p`. The `a`, `b` parameters must be positive double values. The probability `p` must be `a` double on the interval [0, 1].

**Parameters**

- `a`: `double`
- `b`: `double`
- `p`: `double`

## `laplace_cdf(mean, scale, value)`
source: https://docs.chalk.ai/chalksql-docs#laplace_cdf

Compute the Laplace cdf with given `mean` and `scale` parameters: P(N < `value`; `mean`, `scale`). The `mean` and `value` must be real values and the `scale` parameter must be a positive `value` (all of type DOUBLE).

**Parameters**

- `mean`: `double`
- `scale`: `double`
- `value`: `double`
  The input `value`.

## `normal_cdf(mean, sd, value)`
source: https://docs.chalk.ai/chalksql-docs#normal_cdf

Compute the Normal cdf with given `mean` and standard deviation (`sd`): P(N < `value`; `mean`, `sd`). The `mean` and `value` must be real values and the standard deviation must be a real and positive `value` (all of type DOUBLE).

**Parameters**

- `mean`: `double`
- `sd`: `double`
- `value`: `double`
  The input `value`.

## `poisson_cdf(lambda, value)`
source: https://docs.chalk.ai/chalksql-docs#poisson_cdf

Compute the Poisson cdf with given `lambda` (mean) parameter: P(N <= `value`; `lambda`). The `lambda` parameter must be a positive real number (of type DOUBLE) and `value` must be a non-negative integer.

**Parameters**

- `lambda`: `double`
- `value`: `int32`
  The input `value`.

## `weibull_cdf(a, b, value)`
source: https://docs.chalk.ai/chalksql-docs#weibull_cdf

Compute the Weibull cdf with given parameters `a`, `b`: P(N <= `value`). The `a` and `b` parameters must be positive doubles and `value` must also be `a` double.

**Parameters**

- `a`: `double`
- `b`: `double`
- `value`: `double`
  The input `value`.

## `width_bucket(x, bound1, ...+2)`
source: https://docs.chalk.ai/chalksql-docs#width_bucket

Returns the bucket number for a value in a histogram with uniform bucket widths.

**Parameters**

- `x`: `double`
  The input value.
- `bound1`: `double`
- `bound2`: `double`
- `n`: `int64`
  The number of equal-width buckets.

## `wilson_interval_lower(successes, trials, z)`
source: https://docs.chalk.ai/chalksql-docs#wilson_interval_lower

Returns the lower bound of the Wilson score interval of a Bernoulli trial process at a confidence specified by the `z`-score `z`.

**Parameters**

- `successes`: `int64`
  The number of `successes`.
- `trials`: `int64`
  The number of `trials`.
- `z`: `double`
  The `z`-score for the confidence level.

## `wilson_interval_upper(successes, trials, z)`
source: https://docs.chalk.ai/chalksql-docs#wilson_interval_upper

Returns the upper bound of the Wilson score interval of a Bernoulli trial process at a confidence specified by the `z`-score `z`.

**Parameters**

- `successes`: `int64`
  The number of `successes`.
- `trials`: `int64`
  The number of `trials`.
- `z`: `double`
  The `z`-score for the confidence level.
