This topic describes the syntax of mathematical statistics functions. This topic also provides examples on how to use the functions.

Log Service supports the following mathematical statistics functions.

Important If you want to use strings in analytic statements, you must enclose the strings in single quotation marks (''). Strings that are not enclosed or strings that are enclosed in double quotation marks ("") indicate field names or column names. For example, 'status' indicates the status string, and status or "status" indicates the status log field.
CategoryFunctionSyntaxDescription
Correlation functionscorr functioncorr(x, y)Returns the coefficient of correlation between x and y. The return value is in the range of [0,1].
Variance and standard deviation functionscovar_pop functioncovar_pop(x, y)Returns the population covariance of x and y.
covar_samp functioncovar_samp(x, y)Returns the sample covariance of x and y.
stddev functionstddev(x)Returns the sample standard deviation of x. This function is equivalent to the stddev_samp function.
stddev_samp functionstddev_samp(x)Returns the sample standard deviation of x.
stddev_pop functionstddev_pop(x)Returns the population standard deviation of x.
variance functionvariance(x)Returns the sample variance of x. This function is equivalent to the var_samp function.
var_samp functionvar_samp(x)Returns the sample variance of x.
var_pop functionvar_pop(x)Returns the population variance of x.
Linear regression functionsregr_intercept functionregr_intercept(y, x)Returns the y-intercept of the line for the linear equation that is determined by the (x,y) pair.
regr_slope functionregr_slope(y, x)Returns the slope of the line for the linear equation that is determined by the (x,y) pair.
Cumulative distribution functions (CDFs)beta_cdf functionbeta_cdf(α, β, v)Returns a value for the beta distribution. The function uses the following formula: P(N <= v; α, β) where α and β are parameters for the beta CDF.
binomial_cdf functionbinomial_cdf(x, y, v)Returns a value for the binomial distribution. The function uses the following formula: P(N <= v; x, y) where x indicates the number of trials, and y indicates the probability of success (POS) of a trial.
cauchy_cdf functioncauchy_cdf(x, y, v)Returns a value for the Cauchy distribution. The function uses the following formula: P(N <= v; x, y) where x is the location parameter indicating the peak of the distribution, and y is the scale parameter.
chi_squared_cdf functionchi_squared_cdf(k, v)Returns a value for the chi-square distribution. The function uses the following formula: P(N <= v; k) where k indicates the degree of freedom.
inverse_beta_cdf functioninverse_beta_cdf(α, β, p)Returns a value for the inverse of the beta distribution. p indicates the result of the beta CDF, which uses the P(N <= v; α, β) formula. The inverse inverse_beta_cdf function calculates v.
inverse_binomial_cdf functioninverse_binomial_cdf(x, y, p)Returns a value for the inverse of the binomial distribution. p indicates the result of the binomial CDF, which uses the P(N <= v; x, y) formula. The inverse inverse_binomial_cdf function calculates v.
inverse_cauchy_cdf functioninverse_cauchy_cdf(x, y, p)Returns a value for the inverse of the Cauchy distribution. p indicates the result of the Cauchy CDF, which uses the P(N <= v; x, y) formula. The inverse inverse_cauchy_cdf function calculates v.
inverse_chi_squared_cdf functioninverse_chi_squared_cdf(k, p)Returns a value for the inverse of the chi-square distribution. p indicates the result of the chi-square CDF, which uses the P(N <= v; k) formula. The inverse inverse_chi_squared_cdf function calculates v.
inverse_laplace_cdf functioninverse_laplace_cdf(μ, b, p)Returns a value for the inverse of the Laplace distribution. p indicates the result of the Laplace CDF, which uses the P(N <= v; μ, b) formula. The inverse inverse_laplace_cdf function calculates v.
inverse_normal_cdf functioninverse_normal_cdf(x, y, p)Returns a value for the inverse of the normal distribution. p indicates the result of the normal CDF, which uses the P(N < v; x, y) formula. The inverse inverse_normal_cdf function calculates v.
inverse_poisson_cdf functioninverse_poisson_cdf(x, y, p)Returns a value for the inverse of the Poisson distribution. p indicates the result of the Poisson CDF, which uses the P(N <= v; λ) formula. The inverse inverse_poisson_cdf function calculates v.
inverse_weibull_cdf functioninverse_weibull_cdf(x, y, p)Returns a value for the inverse of the Weibull distribution. p indicates the result of the Weibull CDF, which uses the P(N <= v; x, y) formula. The inverse inverse_weibull_cdf function calculates v.
laplace_cdf functionlaplace_cdf( μ, b, v)Returns a value for the Laplace distribution. The function uses the following formula: P(N <= v; μ, b) where μ is the location parameter, and b is the scale parameter.
normal_cdf functionnormal_cdf(x, y, v)Returns a value for the normal distribution. The function uses the following formula: P(N < v; x, y) where x indicates the mean value for the normal distribution, and y indicates the standard deviation for the normal distribution.
poisson_cdf functionpoisson_cdf( λ, v)Returns a value for the Poisson distribution. The function uses the following formula: P(N <= v; λ) where λ indicates the average probability of random events.
weibull_cdf functionweibull_cdf(x, y, v)Returns a value for the Weibull distribution. The function uses the following formula: P(N <= v; x, y) where x is the scale parameter, and y is the shape parameter.

## corr function

The corr function returns the coefficient of correlation between x and y. A larger return value indicates a higher correlation.

corr(x, y)

### Parameters

ParameterDescription
xThe value of this parameter is of the double type.
yThe value of this parameter is of the double type.

### Response

The double type. The return value is in the range of [0,1].

### Examples

Calculate the coefficient of correlation between the values of the request_length and request_time fields.

• Query statement
* | SELECT corr(request_length,request_time)
• Query and analysis results

## covar_pop function

The covar_pop function returns the population covariance of x and y.

covar_pop(x, y)

### Parameters

ParameterDescription
xThe value of this parameter is of the double type.
yThe value of this parameter is of the double type.

The double type.

### Examples

Calculate the population covariance of pretax profits and pretax turnovers in each minute.

• Query statement
*|
SELECT
covar_pop(PretaxGrossAmount, PretaxAmount) AS "Population covariance",
time_series(__time__, '1m', '%H:%i:%s', '0') AS time
GROUP BY
time
• Query and analysis results

## covar_samp function

The covar_samp function returns the sample covariance of x and y.

covar_samp(x, y)

### Parameters

ParameterDescription
xThe value of this parameter is of the double type.
yThe value of this parameter is of the double type.

The double type.

### Examples

Calculate the sample covariance of pretax profits and pretax turnovers in each minute.

• Query statement
*|
SELECT
covar_samp(PretaxGrossAmount, PretaxAmount) AS "Sample covariance",
time_series(__time__, '1m', '%H:%i:%s', '0') AS time
GROUP BY
time
• Query and analysis results

## stddev function

The stddev function returns the sample standard deviation of x. This function is equivalent to the stddev_samp function.

stddev(x)

### Parameters

ParameterDescription
xThe value of this parameter is of the double or bigint type.

The double type.

### Examples

Calculate the sample standard deviation and population standard deviation of pretax incomes and display the calculated values in a line chart.

• Query statement
* |
SELECT
stddev(PretaxGrossAmount) as "Sample standard deviation",
stddev_pop(PretaxGrossAmount) as "Population standard deviation",
time_series(__time__, '1m', '%H:%i:%s', '0') AS time
GROUP BY
time
• Query and analysis results

## stddev_samp function

The stddev_samp function returns the sample standard deviation of x.

stddev_samp(x)

### Parameters

ParameterDescription
xThe value of this parameter is of the double or bigint type.

The double type.

### Examples

Calculate the sample standard deviation and population standard deviation of pretax incomes and display the calculated values in a line chart.

• Query statement
* |
SELECT
stddev_samp(PretaxGrossAmount) as "Sample standard deviation",
stddev_pop(PretaxGrossAmount) as "Population standard deviation",
time_series(__time__, '1m', '%H:%i:%s', '0') AS time
GROUP BY
time
• Query and analysis results

## stddev_pop function

The stddev_pop function returns the population standard deviation of x.

stddev_pop(x)

### Parameters

ParameterDescription
xThe value of this parameter is of the double or bigint type.

The double type.

### Examples

Calculate the sample standard deviation and population standard deviation of pretax incomes and display the calculated values in a line chart.

• Query statement
* |
SELECT
stddev(PretaxGrossAmount) as "Sample standard deviation",
stddev_pop(PretaxGrossAmount) as "Population standard deviation",
time_series(__time__, '1m', '%H:%i:%s', '0') AS time
GROUP BY
time
• Query and analysis results

## variance function

The variance function returns the sample variance of x. This function is equivalent to the var_samp function.

variance(x)

### Parameters

ParameterDescription
xThe value of this parameter is of the double or bigint type.

The double type.

### Examples

Calculate the sample variance and population variance of pretax incomes and display the calculated values in a line chart.

• Query statement
* |
SELECT
variance(PretaxGrossAmount) as "Sample variance",
var_pop(PretaxGrossAmount) as "Population variance",
time_series(__time__, '1m', '%H:%i:%s', '0') as time
GROUP BY
time
• Query and analysis results

## var_samp function

The var_samp function returns the sample variance of x.

var_samp(x)

### Parameters

ParameterDescription
xThe value of this parameter is of the double or bigint type.

The double type.

### Examples

Calculate the sample variance and population variance of pretax incomes and display the calculated values in a line chart.

• Query statement
* |
SELECT
var_samp(PretaxGrossAmount) as "Sample variance",
var_pop(PretaxGrossAmount) as "Population variance",
time_series(__time__, '1m', '%H:%i:%s', '0') as time
GROUP BY
time
• Query and analysis results

## var_pop function

The var_pop function returns the population variance of x.

var_pop(x)

### Parameters

ParameterDescription
xThe value of this parameter is of the double or bigint type.

The double type.

### Examples

Calculate the sample variance and population variance of pretax incomes and display the calculated values in a line chart.

• Query statement
* |
SELECT
variance(PretaxGrossAmount) as "Sample variance",
var_pop(PretaxGrossAmount) as "Population variance",
time_series(__time__, '1m', '%H:%i:%s', '0') as time
GROUP BY
time
• Query and analysis results

## regr_intercept function

The regr_intercept function returns the y-intercept of the line for the linear equation that is determined by the (x,y) pair. x is the dependent value. y is the independent value.

### Syntax

regr_intercept(y, x)

### Parameters

ParameterDescription
yThe value of this parameter is of the double type.
xThe value of this parameter is of the double type.

The double type.

### Examples

Calculate the y-intercept of the line for the linear equation that is determined by the values of the request_time and request_length fields.

• Query statement
* | SELECT regr_intercept(request_length,request_time)
• Query and analysis results

## regr_slope function

The regr_slope function returns the slope of the line for the linear equation that is determined by the (x,y) pair. x is the dependent value. y is the independent value.

regr_slope(y, x)

### Parameters

ParameterDescription
yThe value of this parameter is of the double type.
xThe value of this parameter is of the double type.

The double type.

### Examples

Calculate the slope of the line for the linear equation that is determined by the values of the request_time and request_length fields.

• Query statement
* | SELECT regr_slope(request_length,request_time)
• Query and analysis results

## beta_cdf function

The beta_cdf function returns a value for the beta distribution.

### Syntax

beta_cdf(α, β, v)

### Parameters

ParameterDescription
αThe parameter for the beta CDF. The value of this parameter is of the double type. The value is greater than 0.
βThe parameter for the beta CDF. The value of this parameter is of the double type. The value is greater than 0.
vThe input parameter for the beta CDF. The value of this parameter is of the double type. Valid values: [0,1].

The double type.

### Examples

• Query statement
* | SELECT beta_cdf(0.1, 0.5, 0.7)
• Query and analysis results

## binomial_cdf function

The binomial_cdf function returns a value for the binomial distribution.

### Syntax

binomial_cdf(x, y, v)

### Parameters

ParameterDescription
xThe number of trials. The value of this parameter is of the integer type. The value is greater than 0.
yThe POS of a trial. The value of this parameter is of the double type. Valid values: [0,1].
vThe input parameter for the binomial CDF. The value of this parameter is of the integer type.

The double type.

### Examples

• Query statement
* | select binomial_cdf(10, 0.1, 1)
• Query and analysis results

## cauchy_cdf function

The cauchy_cdf function returns a value for the Cauchy distribution.

### Syntax

cauchy_cdf(x, y, v)

### Parameters

ParameterDescription
xThe location parameter that indicates the peak of the distribution. The value of this parameter is of the double type.
yThe scale parameter. The value of this parameter is of the double type. The value is greater than 0.
vThe input parameter for the Cauchy CDF. The value of this parameter is of the double type.

The double type.

### Examples

• Query statement
* | select cauchy_cdf(-10, 5, -12)
• Query and analysis results

## chi_squared_cdf function

The chi_squared_cdf function returns a value for the chi-square distribution.

### Syntax

chi_squared_cdf(k, v)

### Parameters

ParameterDescription
kThe degree of freedom. The value of this parameter is of the double type. The value is greater than 0.
vThe input parameter of the chi-square CDF. The value of this parameter is of the double type. The value is greater than or equal to 0.

The double type.

### Examples

• Query statement
* | select chi_squared_cdf(3, 10)
• Query and analysis results

## inverse_beta_cdf function

The inverse_beta_cdf function returns a value for the inverse of the beta distribution.

### Syntax

inverse_beta_cdf(α, β, p)

### Parameters

ParameterDescription
αThe parameter for the beta CDF. The value of this parameter is of the double type. The value is greater than 0.
βThe parameter for the beta CDF. The value of this parameter is of the double type. The value is greater than 0.
pThe input parameter for the inverse of the beta CDF. The value of this parameter is of the double type. Valid values: [0,1].

The double type.

### Examples

• Query statement
* | select inverse_beta_cdf(0.1, 0.5, 0.8926585878364057)
• Query and analysis results

## inverse_binomial_cdf function

The inverse_binomial_cdf function returns a value for the inverse of the binomial distribution.

### Syntax

inverse_binomial_cdf(x, y, p)

### Parameters

ParameterDescription
xThe number of trials. The value of this parameter is of the integer type. The value is greater than 0.
yThe POS of a trial. The value of this parameter is of the double type. Valid values: [0,1].
pThe input parameter for the inverse of the binomial CDF. The value of this parameter is of the double type. Valid values: [0,1].

### Response

The integer type.

### Examples

• Query statement
* | select inverse_binomial_cdf(10, 0.1, 0.7360989291000001)
• Query and analysis results

## inverse_cauchy_cdf function

The inverse_cauchy_cdf function returns a value for the inverse of the Cauchy distribution.

### Syntax

inverse_cauchy_cdf(x, y, p)

### Parameters

ParameterDescription
xThe location parameter that indicates the peak of the distribution. The value of this parameter is of the double type.
yThe scale parameter. The value of this parameter is of the double type. The value is greater than 0.
pThe input parameter for the inverse of the Cauchy CDF. The value of this parameter is of the double type. Valid values: [0,1].

The double type.

### Examples

• Query statement
* | select inverse_cauchy_cdf(-10, 5, 0.3788810584091566)
• Query and analysis results

## inverse_chi_squared_cdf function

The inverse_chi_squared_cdf function returns a value for the inverse of the chi-square distribution.

### Syntax

chi_squared_cdf(k, p)

### Parameters

ParameterDescription
kThe degree of freedom. The value of this parameter is of the double type. The value is greater than 0.
pThe input parameter for the inverse of the chi-square CDF. The value of this parameter is of the double type. Valid values: [0,1].

The double type.

### Examples

• Query statement
* | select inverse_chi_squared_cdf(3, 0.9814338645369567)
• Query and analysis results

## inverse_laplace_cdf function

The inverse_laplace_cdf function returns a value for the inverse of the Laplace distribution.

### Syntax

inverse_laplace_cdf(μ, b, p)

### Parameters

ParameterDescription
μThe location parameter for the Laplace CDF. The value of this parameter is of the double type.
bThe scale parameter for the Laplace CDF. The value of this parameter is of the double type. The value is greater than 0.
pThe input parameter for the inverse of the Laplace CDF. The value of this parameter is of the double type. Valid values: [0,1].

The double type.

### Examples

• Query statement
* | select inverse_laplace_cdf(11, 0.5, 0.18393972058572118)
• Query and analysis results

## inverse_normal_cdf function

The inverse_normal_cdf function returns a value for the inverse of the normal distribution.

### Syntax

inverse_normal_cdf(x, y, p)

### Parameters

ParameterDescription
xThe mean value for the normal distribution. The value of this parameter is of the double type.
yThe standard deviation for the normal distribution. The value of this parameter is of the double type. The value is greater than 0.
pThe input parameter for the inverse of the normal CDF. The value of this parameter is of the double type. Valid values: (0,1).

The double type.

### Examples

• Query statement
* | select inverse_normal_cdf(85, 10, 0.06680720126885803)
• Query and analysis results

## inverse_poisson_cdf function

The inverse_poisson_cdf function returns a value for the inverse of the Poisson distribution.

### Syntax

inverse_poisson_cdf(λ, p)

### Parameters

ParameterDescription
λThe average probability of random events.
pThe input parameter for the inverse of the Poisson CDF. The value of this parameter is of the double type. Valid values: [0,1].

### Response

The integer type.

### Examples

• Query statement
* | select inverse_poisson_cdf(0.1, 0.9953211598395556)
• Query and analysis results

## inverse_weibull_cdf function

The inverse_weibull_cdf function returns a value for the inverse of the Weibull distribution.

### Syntax

inverse_weibull_cdf(x, y, p)

### Parameters

ParameterDescription
xThe scale parameter for the Weibull CDF. The value of this parameter is of the double type. The value is greater than 0.
yThe shape parameter for the Weibull CDF. The value of this parameter is of the double type. The value is greater than 0.
pThe input parameter for the inverse of the Weibull CDF. The value of this parameter is of the double type. Valid values: [0,1].

The double type.

### Examples

• Query statement
* | select inverse_weibull_cdf(1, 5, 0.3296799539643607)
• Query and analysis results

## laplace_cdf function

The laplace_cdf function returns a value for the Laplace distribution.

### Syntax

laplace_cdf(μ, b, v)

### Parameters

ParameterDescription
μThe location parameter for the Laplace CDF. The value of this parameter is of the double type.
bThe scale parameter for the Laplace CDF. The value of this parameter is of the double type. The value is greater than 0.
vThe input parameter for the Laplace CDF. The value of this parameter is of the double type.

The double type.

### Examples

• Query statement
* | select laplace_cdf(11, 0.5, 10.5)
• Query and analysis results

## normal_cdf function

The normal_cdf function returns a value for the normal distribution.

### Syntax

normal_cdf(x, y, v)

### Parameters

ParameterDescription
xThe mean value for the normal distribution. The value of this parameter is of the double type.
yThe standard deviation for the normal distribution. The value of this parameter is of the double type. The value is greater than 0.
vThe input parameter for the normal CDF. The value of this parameter is of the double type.

The double type.

### Examples

• Query statement
* | select normal_cdf(85, 10, 70)
• Query and analysis results

## poisson_cdf function

The poisson_cdf function returns a value for the Poisson distribution.

### Syntax

poisson_cdf(λ, v)

### Parameters

ParameterDescription
λThe average probability of random events.
vThe input parameter for the Poisson CDF. The value of this parameter is of the integer type. The value is greater than or equal to 0.

The double type.

### Examples

• Query statement
* | select poisson_cdf(0.1, 1)
• Query and analysis results

## weibull_cdf function

The weibull_cdf function returns a value for the Weibull distribution.

### Syntax

weibull_cdf(x, y, v)

### Parameters

ParameterDescription
xThe scale parameter for the Weibull CDF. The value of this parameter is of the double type. The value is greater than 0.
yThe shape parameter for the Weibull CDF. The value of this parameter is of the double type. The value is greater than 0.
vThe input parameter for the Weibull CDF. The value of this parameter is of the double type.

### Examples

• Query statement
* | select weibull_cdf(1, 5, 2)
• Query and analysis results