All Products
Search
Document Center

Simple Log Service:Mathematical statistics functions

Last Updated:Feb 26, 2024

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

The following table describes the mathematical statistics functions that are supported by Simple Log Service.

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.

Category

Function

Syntax

Description

Supported in SQL

Supported in SPL

Correlation function

corr function

corr(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 functions

covar_pop function

covar_pop(x, y)

Returns the population covariance of x and y.

×

covar_samp function

covar_samp(x, y)

Returns the sample covariance of x and y.

×

stddev function

stddev(x)

Returns the sample standard deviation of x. This function is equivalent to the stddev_samp function.

×

stddev_samp function

stddev_samp(x)

Returns the sample standard deviation of x.

×

stddev_pop function

stddev_pop(x)

Returns the population standard deviation of x.

×

variance function

variance(x)

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

×

var_samp function

var_samp(x)

Returns the sample variance of x.

×

var_pop function

var_pop(x)

Returns the population variance of x.

×

Linear regression functions

regr_intercept function

regr_intercept(y, x)

Returns the y-intercept of the line for the linear equation that is determined by the (x,y) pair.

×

regr_slope function

regr_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 function

beta_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 function

binomial_cdf(x, y, v)

Returns a value for the binomial distribution. The function uses the following formula: P(N <= v), where x indicates the number of trials, and y indicates the probability of success (POS) of a trial.

×

cauchy_cdf function

cauchy_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 function

chi_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 function

inverse_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 function

inverse_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) formula. The inverse inverse_binomial_cdf function calculates v.

×

inverse_cauchy_cdf function

inverse_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 function

inverse_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 function

inverse_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 function

inverse_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 function

inverse_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 function

inverse_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 function

laplace_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 function

normal_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 function

poisson_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 function

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

Syntax

corr(x, y)

Parameters

Parameter

Description

x

The value of this parameter is of the double type.

y

The value of this parameter is of the double type.

Return value type

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 resultscorr函数

covar_pop function

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

Syntax

covar_pop(x, y)

Parameters

Parameter

Description

x

The value of this parameter is of the double type.

y

The value of this parameter is of the double type.

Return value 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 resultscovar_pop

covar_samp function

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

Syntax

covar_samp(x, y)

Parameters

Parameter

Description

x

The value of this parameter is of the double type.

y

The value of this parameter is of the double type.

Return value 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 resultscovar_samp

stddev function

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

Syntax

stddev(x)

Parameters

Parameter

Description

x

The value of this parameter is of the double or bigint type.

Return value 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 resultsstddev_pop函数

stddev_samp function

The stddev_samp function returns the sample standard deviation of x.

Syntax

stddev_samp(x)

Parameters

Parameter

Description

x

The value of this parameter is of the double or bigint type.

Return value 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 resultsstddev_pop函数

stddev_pop function

The stddev_pop function returns the population standard deviation of x.

Syntax

stddev_pop(x)

Parameters

Parameter

Description

x

The value of this parameter is of the double or bigint type.

Return value 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 resultsstddev_pop函数

variance function

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

Syntax

variance(x)

Parameters

Parameter

Description

x

The value of this parameter is of the double or bigint type.

Return value 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 resultsvariance

var_samp function

The var_samp function returns the sample variance of x.

Syntax

var_samp(x)

Parameters

Parameter

Description

x

The value of this parameter is of the double or bigint type.

Return value 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 resultsvariance

var_pop function

The var_pop function returns the population variance of x.

Syntax

var_pop(x)

Parameters

Parameter

Description

x

The value of this parameter is of the double or bigint type.

Return value 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 resultsvariance

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

Parameter

Description

y

The value of this parameter is of the double type.

x

The value of this parameter is of the double type.

Return value 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 resultsregr_slope

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.

Syntax

regr_slope(y, x)

Parameters

Parameter

Description

y

The value of this parameter is of the double type.

x

The value of this parameter is of the double type.

Return value 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 resultsregr_slope

beta_cdf function

The beta_cdf function returns a value for the beta distribution.

Syntax

beta_cdf(α, β, v)

Parameters

Parameter

Description

α

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.

v

The input parameter for the beta CDF. The value of this parameter is of the double type. Value range: [0,1].

Return value type

The double type.

Examples

  • Query statement

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

binomial_cdf function

The binomial_cdf function returns a value for the binomial distribution.

Syntax

binomial_cdf(x, y, v)

Parameters

Parameter

Description

x

The number of trials. The value of this parameter is of the integer type. The value is greater than 0.

y

The POS of a trial. The value of this parameter is of the double type. Value range: [0,1].

v

The input parameter for the binomial CDF. The value of this parameter is of the integer type.

Return value type

The double type.

Examples

  • Query statement

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

cauchy_cdf function

The cauchy_cdf function returns a value for the Cauchy distribution.

Syntax

cauchy_cdf(x, y, v)

Parameters

Parameter

Description

x

The location parameter that indicates the peak of the distribution. The value of this parameter is of the double type.

y

The scale parameter. The value of this parameter is of the double type. The value must be greater than 0.

v

The input parameter for the Cauchy CDF. The value of this parameter is of the double type.

Return value type

The double type.

Examples

  • Query statement

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

chi_squared_cdf function

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

Syntax

chi_squared_cdf(k, v)

Parameters

Parameter

Description

k

The degree of freedom. The value of this parameter is of the double type. The value is greater than 0.

v

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

Return value type

The double type.

Examples

  • Query statement

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

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

Parameter

Description

α

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.

p

The input parameter for the inverse of the beta CDF. The value of this parameter is of the double type. Value range: [0,1].

Return value type

The double type.

Examples

  • Query statement

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

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

Parameter

Description

x

The number of trials. The value of this parameter is of the integer type. The value is greater than 0.

y

The POS of a trial. The value of this parameter is of the double type. Value range: [0,1].

p

The input parameter for the inverse of the binomial CDF. The value of this parameter is of the double type. Value range: [0,1].

Return value type

The integer type.

Examples

  • Query statement

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

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

Parameter

Description

x

The location parameter that indicates the peak of the distribution. The value of this parameter is of the double type.

y

The scale parameter. The value of this parameter is of the double type. The value is greater than 0.

p

The input parameter for the inverse of the Cauchy CDF. The value of this parameter is of the double type. Value range: [0,1].

Return value type

The double type.

Examples

  • Query statement

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

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

Parameter

Description

k

The degree of freedom. The value of this parameter is of the double type. The value is greater than 0.

p

The input parameter for the inverse of the chi-square CDF. The value of this parameter is of the double type. Value range: [0,1].

Return value type

The double type.

Examples

  • Query statement

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

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

Parameter

Description

μ

The location parameter for the Laplace CDF. The value of this parameter is of the double type.

b

The scale parameter for the Laplace CDF. The value of this parameter is of the double type. The value is greater than 0.

p

The input parameter for the inverse of the Laplace CDF. The value of this parameter is of the double type. Value range: [0,1].

Return value type

The double type.

Examples

  • Query statement

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

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

Parameter

Description

x

The mean value for the normal distribution. The value of this parameter is of the double type.

y

The standard deviation for the normal distribution. The value of this parameter is of the double type. The value is greater than 0.

p

The input parameter for the inverse of the normal CDF. The value of this parameter is of the double type. Valid values: (0,1).

Return value type

The double type.

Examples

  • Query statement

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

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

Parameter

Description

λ

The average probability of random events.

p

The input parameter for the inverse of the Poisson CDF. The value of this parameter is of the double type. Value range: [0,1].

Return value type

The integer type.

Examples

  • Query statement

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

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

Parameter

Description

x

The scale parameter for the Weibull CDF. The value of this parameter is of the double type. The value is greater than 0.

y

The shape parameter for the Weibull CDF. The value of this parameter is of the double type. The value is greater than 0.

p

The input parameter for the inverse of the Weibull CDF. The value of this parameter is of the double type. Valid values: [0,1].

Return value type

The double type.

Examples

  • Query statement

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

laplace_cdf function

The laplace_cdf function returns a value for the Laplace distribution.

Syntax

laplace_cdf(μ, b, v)

Parameters

Parameter

Description

μ

The location parameter for the Laplace CDF. The value of this parameter is of the double type.

b

The scale parameter for the Laplace CDF. The value of this parameter is of the double type. The value is greater than 0.

v

The input parameter for the Laplace CDF. The value of this parameter is of the double type.

Return value type

The double type.

Examples

  • Query statement

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

normal_cdf function

The normal_cdf function returns a value for the normal distribution.

Syntax

normal_cdf(x, y, v)

Parameters

Parameter

Description

x

The mean value for the normal distribution. The value of this parameter is of the double type.

y

The standard deviation for the normal distribution. The value of this parameter is of the double type. The value is greater than 0.

v

The input parameter for the normal CDF. The value of this parameter is of the double type.

Return value type

The double type.

Examples

  • Query statement

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

poisson_cdf function

The poisson_cdf function returns a value for the Poisson distribution.

Syntax

poisson_cdf(λ, v)

Parameters

Parameter

Description

λ

The average probability of random events.

v

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

Return value type

The double type.

Examples

  • Query statement

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

weibull_cdf function

The weibull_cdf function returns a value for the Weibull distribution.

Syntax

weibull_cdf(x, y, v)

Parameters

Parameter

Description

x

The scale parameter for the Weibull CDF. The value of this parameter is of the double type. The value is greater than 0.

y

The shape parameter for the Weibull CDF. The value of this parameter is of the double type. The value is greater than 0.

v

The input parameter for the Weibull CDF. The value of this parameter is of the double type.

Return value type

Examples

  • Query statement

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