zscore
Syntax
zscore(X)
Details
If X is a vector, return the zscore for all elements of X.
If X is a matrix or table, the zscore calculation is conducted within each column of X.
As with all aggregate functions, null values are not included in the calculation.
Note:
DolphinDB zscore and scipy.stats.zscore are both used to
calculate standard scores (Z-scores). The differences are as follows:
- DolphinDB
zscoreuses the sample standard deviation for calculation, whilescipy.stats.zscoreuses the population standard deviation by default. To obtain results consistent with DolphinDBzscore, you should specify ddof=1. - DolphinDB
zscoreautomatically ignores NULL values, whereasscipy.stats.zscorepropagates NaN values by default. To ignore missing values, you should specify nan_policy='omit'. - DolphinDB
zscoresupports only one parameter, X, whilescipy.stats.zscoreprovides more flexible control over calculation behavior through parameters such as axis, ddof, and nan_policy.
Parameters
X is a vector/matrix/table.
Returns
If X is a vector, a vector of the same length as X is returned. If X is a matrix or a table, a matrix or table with the same number of rows and columns as X is returned.
Examples
zscore(1 2 3 4 5);
// output: [-1.264911,-0.632456,0,0.632456,1.264911]
m=matrix(1 2 3, 4 5 6);
m;
| #0 | #1 |
|---|---|
| 1 | 4 |
| 2 | 5 |
| 3 | 6 |
zscore(m);
| #0 | #1 |
|---|---|
| -1 | -1 |
| 0 | 0 |
| 1 | 1 |
