跳转至

Sample covariance(样本协方差(Sample covariance))

Supported in: Batch, Streaming

Calculate the sample covariance of values in two columns.

Expression categories: Aggregate

Declared arguments

  • Left: The first column on which we compute covariance.
    Expression\
  • Right: The second column on which we compute covariance.
    Expression\

Output type: Double

Examples

Example 1: Base case

Argument values:

  • Left: left
  • Right: right

Given input table:

left right
1 5
2 4
3 3
4 2
5 1

Outputs: -2.5


Example 2: Null case

Argument values:

  • Left: left
  • Right: right

Given input table:

left right
1.0 2.0
null null
2.0 1.0

Outputs: -0.5



中文翻译


样本协方差(Sample covariance)

支持:批处理(Batch)、流处理(Streaming)

计算两列数值的样本协方差。

表达式类别: 聚合(Aggregate)

声明的参数

  • 左列(Left): 用于计算协方差的第一列。
    表达式\<数值类型>
  • 右列(Right): 用于计算协方差的第二列。
    表达式\<数值类型>

输出类型: 双精度浮点数(Double)

示例

示例 1:基础情况

参数值:

  • 左列: left
  • 右列: right

给定输入表:

left right
1 5
2 4
3 3
4 2
5 1

输出结果: -2.5


示例 2:空值情况

参数值:

  • 左列: left
  • 右列: right

给定输入表:

left right
1.0 2.0
null null
2.0 1.0

输出结果: -0.5