var
Syntax
var(X)
Details
If X is a vector, return the the (unbiased) sample standard variance of X.
If X is a matrix, calculate the the (unbiased) sample standard variance of each column of X and return a vector.
As with all aggregate functions, null values are not included in the calculation.
Note:
DolphinDB var and numpy.var are both used to calculate
variance. The differences are as follows:
- DolphinDB
varreturns the unbiased sample variance, whilenumpy.varreturns the population variance by default. To obtain results consistent with DolphinDBvar, you should specify ddof=1 in NumPy. - DolphinDB
varautomatically ignores NULL values, whereasnumpy.vardoes not automatically skip NaN values, so the result may beNaN. - Regarding computation dimensions, DolphinDB
varcalculates the variance column by column for matrices, whilenumpy.varflattens the array and calculates the variance over all elements by default. You can also specify the computation dimension using the axis parameter.
Parameters
X is a scalar/vector/matrix.
Returns
A DOUBLE scalar/vector/table.
