StdDocs
The Std Operation
Computes the standard deviation of values — a measure of how spread out the values are around their mean.
All primitive number types are supported: Byte, Short, Int, Long, Float, and Double. "Mixed" Number input is supported too, as long as it consists solely of those primitive numbers; its values are then first converted to their common type using UnifiedNumberTypeOptions.PRIMITIVES_ONLY, see number unification. Big numbers (, BigInteger) are not supported; BigDecimal them to a primitive number type first.convert
null values in the input are always ignored.
If the input contains values, the result will be NaNNaN, unless skipNaN is set to true.
The resulting standard deviation is always a Double and never null. Converting Long values to Double may lose precision for very large values.
For more information about the resulting types: See "std Type Conversion" on the documentation website.
Std Modes
Depending on what exactly you want the standard deviation of, there are several modes. They are shown here for DataFrame, but they exist for the other receivers too:
std()— the standard deviation of each suitable column separately.std{ columns }— a single standard deviation of all values in all selected columns.stdFor{ columns }— the standard deviation of each selected column separately.stdOf{ expression }— the standard deviation of the values that the given expression returns for each row.
Delta Degrees of Freedom (ddof)
All std operations take a ("Delta Degrees of Freedom") argument. The divisor used in the calculation is ddofN - ddof, where N is the number of values. The default is 1, meaning DataFrame applies Bessel's correction and computes the "unbiased sample standard deviation" by default (as is standard in languages like R). This is different from the "population standard deviation" (ddof = 0), which is the default in libraries like Numpy.
If the number of values is <= ddof, the result is Double.NaN. So, with the default ddof = 1, the standard deviation of a single value is Double.NaN.
Related operation:
— the average of values (the standard deviation measures the spread around it).mean
For more information: See std on the documentation website.
For more information about unifying numbers: See "Number Unification" on the documentation website.
See all summary statistics: See "Summary statistics" on the documentation website.
Types
"Delta Degrees of Freedom". The divisor used in the calculation is N - ddof, where N is the number of values. The default is 1, which applies Bessel's correction and computes the unbiased sample standard deviation (as in R). Use 0 for the population standard deviation (as in Numpy).
Selecting columns for various DataFrame operations can be done in the following ways:
Selecting columns for various DataFrame operations can be done in the following ways: