参考:http://gpdb.docs.pivotal.io/4390/admin_guide/query/topics/functions-operators.html

Table 4. Advanced Analytic Functions
Function Return Type Full Syntax Description
matrix_add(array[], array[]) smallint[], int[], bigint[], float[] matrix_add( array[[1,1],[2,2]], array[[3,4],[5,6]]) Adds two two-dimensional matrices. The matrices must be conformable.
matrix_multiply( array[], array[]) smallint[]int[], bigint[], float[] matrix_multiply( array[[2,0,0],[0,2,0],[0,0,2]], array[[3,0,3],[0,3,0],[0,0,3]] ) Multiplies two, three- dimensional arrays. The matrices must be conformable.
matrix_multiply( array[], expr) int[], float[] matrix_multiply( array[[1,1,1], [2,2,2], [3,3,3]], 2) Multiplies a two-dimensional array and a scalar numeric value.
matrix_transpose( array[]) Same as input arraytype. matrix_transpose( array [[1,1,1],[2,2,2]]) Transposes a two-dimensional array.
pinv(array []) smallint[]int[], bigint[], float[] pinv(array[[2.5,0,0],[0,1,0],[0,0,.5]]) Calculates the Moore-Penrose pseudoinverse of a matrix.
unnest (array[]) set of anyelement unnest( array['one', 'row', 'per', 'item']) Transforms a one dimensional array into rows. Returns a set ofanyelement, a polymorphic pseudotype in PostgreSQL.
Table 5. Advanced Aggregate Functions
Function Return Type Full Syntax Description
MEDIAN (expr) timestamp, timestampz, interval, float MEDIAN (expression)

Example:

SELECT department_id, MEDIAN(salary)
FROM employees
GROUP BY department_id;
Can take a two-dimensional array as input. Treats such arrays as matrices.
PERCENTILE_CONT (expr) WITHIN GROUP (ORDER BYexpr [DESC/ASC]) timestamp, timestampz, interval, float PERCENTILE_CONT(percentage) WITHIN GROUP (ORDER BY expression)

Example:

SELECT department_id,
PERCENTILE_CONT (0.5) WITHIN GROUP (ORDER BY salary DESC)
"Median_cont";
FROM employees GROUP BY department_id;
Performs an inverse function that assumes a continuous distribution model. It takes a percentile value and a sort specification and returns the same datatype as the numeric datatype of the argument. This returned value is a computed result after performing linear interpolation. Null are ignored in this calculation.
PERCENTILE_DISC (expr) WITHIN GROUP (ORDER BYexpr [DESC/ASC]) timestamp, timestampz, interval, float PERCENTILE_DISC(percentage) WITHIN GROUP (ORDER BY expression)

Example:

SELECT department_id,
PERCENTILE_DISC (0.5) WITHIN GROUP (ORDER BY salary DESC)
"Median_desc";
FROM employees GROUP BY department_id;
Performs an inverse distribution function that assumes a discrete distribution model. It takes a percentile value and a sort specification. This returned value is an element from the set. Null are ignored in this calculation.
sum(array[]) smallint[]int[], bigint[], float[] sum(array[[1,2],[3,4]])

Example:

CREATE TABLE mymatrix (myvalue int[]);
INSERT INTO mymatrix VALUES (array[[1,2],[3,4]]);
INSERT INTO mymatrix VALUES (array[[0,1],[1,0]]);
SELECT sum(myvalue) FROM mymatrix;
sum
---------------
{{1,3},{4,4}}
Performs matrix summation. Can take as input a two-dimensional array that is treated as a matrix.
pivot_sum (label[], label, expr) int[], bigint[], float[] pivot_sum( array['A1','A2'], attr, value) A pivot aggregation using sum to resolve duplicate entries.
mregr_coef(expr, array[]) float[] mregr_coef(y, array[1, x1, x2]) The four mregr_*aggregates perform linear regressions using the ordinary-least-squares method. mregr_coefcalculates the regression coefficients. The size of the return array formregr_coef is the same as the size of the input array of independent variables, since the return array contains the coefficient for each independent variable.
mregr_r2 (expr, array[]) float mregr_r2(y, array[1, x1, x2]) The four mregr_*aggregates perform linear regressions using the ordinary-least-squares method. mregr_r2calculates the r-squared error value for the regression.
mregr_pvalues(expr, array[]) float[] mregr_pvalues(y, array[1, x1, x2]) The four mregr_*aggregates perform linear regressions using the ordinary-least-squares method. mregr_pvaluescalculates the p-values for the regression.
mregr_tstats(expr, array[]) float[] mregr_tstats(y, array[1, x1, x2]) The four mregr_*aggregates perform linear regressions using the ordinary-least-squares method. mregr_tstatscalculates the t-statistics for the regression.
nb_classify(text[], bigint, bigint[], bigint[]) text nb_classify(classes, attr_count, class_count, class_total) Classify rows using a Naive Bayes Classifier. This aggregate uses a baseline of training data to predict the classification of new rows and returns the class with the largest likelihood of appearing in the new rows.
nb_probabilities(text[], bigint, bigint[], bigint[]) text nb_probabilities(classes, attr_count, class_count, class_total) Determine probability for each class using a Naive Bayes Classifier. This aggregate uses a baseline of training data to predict the classification of new rows and returns the probabilities that each class will appear in new rows.

greenplum 数组操作的更多相关文章

  1. Javascript数组操作

    使用JS也算有段时日,然对于数组的使用,总局限于很初级水平,且每每使用总要查下API,或者写个小Demo测试下才算放心,一来二去,浪费不少时间:思虑下,堪能如此继续之?当狠心深学下方是正道. 原文链接 ...

  2. JavaScript jQuery 中定义数组与操作及jquery数组操作

    首先给大家介绍javascript jquery中定义数组与操作的相关知识,具体内容如下所示: 1.认识数组 数组就是某类数据的集合,数据类型可以是整型.字符串.甚至是对象Javascript不支持多 ...

  3. php数组操作集锦- 掌握了数组操作, 也就掌握了php

    参考下面的文章, 是很好的: http://www.cnblogs.com/staven/p/5142515.html http://pcwanli.blog.163.com/blog/static/ ...

  4. JavaScript 数组操作

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. JavaScript中数组操作常用方法

    JavaScript中数组操作常用方法 1.检测数组 1)检测对象是否为数组,使用instanceof 操作符 if(value instanceof Array) { //对数组执行某些操作 } 2 ...

  6. php 常用数组操作

    php常用的数组操作函数,包括数组的赋值.拆分.合并.计算.添加.删除.查询.判断.排序等 array_combine 功能:用一个数组的值作为新数组的键名,另一个数组的值作为新数组的值 <?p ...

  7. 005-Scala数组操作实战详解

    005-Scala数组操作实战详解 Worksheet的使用 交互式命令执行平台 记得每次要保存才会出相应的结果 数组的基本操作 数组的下标是从0开始和Tuple不同 缓冲数组ArrayBuffer( ...

  8. JavaScript中常见的数组操作函数及用法

    JavaScript中常见的数组操作函数及用法 昨天写了个帖子,汇总了下常见的JavaScript中的字符串操作函数及用法.今天正好有时间,也去把JavaScript中常见的数组操作函数及用法总结一下 ...

  9. jQuery_03之事件、动画、类数组操作

    一.事件: 1.模式触发事件:  ①DOM:elem.onXXX();只能触发直接用onXXX绑定的事件处理函数:用addEventistener添加的事件监听无法模拟出发触发:  ②jQuery:$ ...

随机推荐

  1. 解决:使用 swiper 自动轮播图片,当拖动过 swiper 内的内容时,导致不继续自动轮播

    版本为1.3 当使用了 swiper 后: var mySwiper = new Swiper('.banner .swiper-container', { autoplay: 3000, loop: ...

  2. jackson处理日期异常

    原 jackson处理日期异常 2018年01月09日 10:50:19 阅读数:70 1.异常信息 2.原因 默认情况下,fasterxml json只支持几种format,但是肯定不支持" ...

  3. pandas 存储文件到MySQL 以及读取

    pandas导入数据到MySQL 1.导入必要的库 2.创建链接 3.导入数据 import pandas as pd from sqlalchemy import create_engine con ...

  4. iOS项目开发日常之创建文件(协议、类、分类、扩展)

    iOS项目开发过程中,是以不断创建文件的形式进行着的. 创建得比较频繁的文件类型是: 这两个类型中创建的文件有:子类.分类.扩展.协议四种文件,如下:    这四类文件是频繁创建的,我们来看一下各自分 ...

  5. python 连接oracle基础环境配置方法

    配置基础: 1.python3.7 2.oracle server 11g 64位 3.PLSQL 64位 4.instantclient-basic-windows.x64-11.2.0.4.0这个 ...

  6. 【PAT甲级】1021 Deepest Root (25 分)(暴力,DFS)

    题意: 输入一个正整数N(N<=10000),然后输入N-1条边,求使得这棵树深度最大的根节点,递增序输出.如果不是一棵树,输出这张图有几个部分. trick: 时间比较充裕数据可能也不是很极限 ...

  7. 六、linux基础-计算机网络_线程_进程

    6 计算机网络-线程和进程6.1 TCP/IP协议 TCP/IP是Unix/Linux世界的网络基础,在某种意义上,Unix网络就是Tcp/ip,而且Tcp/ip就是网络互连的标准他不是一个独立的协议 ...

  8. CSS3-边框(border-radius、box-shadow、border-image)

    CSS3中的边框属性:border-radius.box-shadow.border-image 圆角:border-radius 使用 CSS3 border-radius 属性,你可以给任何元素制 ...

  9. Tomcat 8 Invalid character found in the request target. The valid characters are defined in RFC 3986

    终极解决方案: Invalid character found in the request target. The valid characters are defined in RFC 3986 ...

  10. Codeforces1304F.Animal Observation

    分析一下得知是DP问题,时间复杂度符合,设dp[i][j]为从第i天开始,第j个位置能得到的最大值,其有三种转移状态 1.与上一天的选择有重合 2.与上一天的选择没有重合,且上一天的选择在左边 3.与 ...