Skip to content

← statistics package

Variance

Compute the variance of the data over a given axis.

The chosen axis will be removed from the data and replaced by a new one-element feature axis. In the special case that the variance is taken over time, a dummy time axis will be retained, unless this behavior is overriden using the force feature axis parameter. It is also possible to compute a robust variant of the mean instead. Note that, if you apply this over time on unsegmented streaming data, you are almost certainly doing it wrong, because streaming chunks can be very short, yielding erratic variance values -- more reasonable uses of the variance are on segmented data, or over other axes. If you need a moving-window estimate of variance, and your signal is zero-mean (e.g., highpass filtered), you can also just use a Squaring node followed by a Moving Average node). More Info... Version 1.1.0

Ports/Properties

data

Data to process.

verbose name
Data
default value
None
port type
DataPort
value type
AnyNumeric (can be None)
data direction
INOUT

axis

Axis along which to take the statistic. This axis will drop out of the data and, if keep_axis is set, is replaced by a dummy one-element axis (usually of same type as before, although special cases apply for specific reduction nodes). One may also list a comma-separated list of axes here to reduce over multiple axes at a time. If this is left blank or set to None, then all axes will be reduced over; this can be used to obtain a single value if keep_axis is also set to False. The tree axis is a special case that will reduce over the data structure itself (e.g., dictionary), and the streams axis will reduce over the streams in a packet.

verbose name
Act Along Axis
default value
instance
port type
ComboPort
value type
str (can be None)

axis_occurrence

Index of the occurrence of the axis of desired type. (0 is the first axis of the desired type, 1 is the second, -1 is the last, -2 is the second-to-last, and so on).

verbose name
Axis Occurrence
default value
0
port type
IntPort
value type
int (can be None)

keep_axis

Keep the axis that was reduced as a singleton (one-element) axis in the data. In script usage this can also be set to None to reduce over and drop all axes and return a scalar value (in graph pipelines the same can be achieved by setting the axis to (all axes) and keep_axis to False).

verbose name
Keep Reduced Axis
default value
True
port type
BoolPort
value type
bool (can be None)

kept_axis

New type of the axis that was reduced over, if the keep_axis (keep reduced axis) option is enabled. Setting this to the type of an axis (e.g., feature) will result in a one-element axis of that type in place of the original axis; the value 'same' will yield an axis of the same type as the original axis (and will also preserve the old axis' custom label, if any). The 'legacy' setting will preserve the type of some axes but generate a feature axes for others, and this is not consistent between e.g., Mean, Variance and other statistics (see the "force feature axis" option for full details). The default value will change from 'legacy' to 'same' in a future release. The 'legacy (warn)' setting is like 'legacy' but will additionally issue an actionable one-time warning in which way the node's behavior will transition to a more consitent mode, and how to preserve the current behavior. One may also specify other axis types here. Note that, while one may bake a desired axis label into the axis type here, it is considered bad practice to use the label to annotate the statistic used, especially if the axis should pair correctly with other axes of same type (but perhaps different label) in downstream operations. Use a feature, statistic, or named axis for this purpose, which will record the statistic in the (one-element) axis array instead.

verbose name
Axis If Kept
default value
legacy
port type
ComboPort
value type
str (can be None)

force_feature_axis

Deprecated option used in legacy pipelines. This field should be cleared in modern uses, in which case the kept_axis field takes precedence. Setting this to 'True' will always create a feature axis; setting it to 'False' will preserve the same axis type IF the legacy behavior of the node supported it, and otherwise creates a feature axis. Cases in which a feature axis was created if set to False are as follows: Variance, StandardDeviation, and CurveLength: space, frequency, instance, named, statistic, and axis were reduced to feature. Sum, MedianAbsoluteDeviation, Product, RootMeanSquare: space, named, statistic, and axis were reduced to feature. Mean: lag, named, statistic, and axis were reduced to feature. All, Any, Centroid, Largest, Smallest, Median: lag was reduced to feature.

verbose name
Force Feature Axis (Legacy)
default value
None
port type
Port
value type
object (can be None)

degrees_of_freedom

Number of degrees of freedom to subtract. Setting this to 1 amounts applying Bessel's correction, which yields an unbiased estimate of the (infinite) population variance from which the sample is assumed to be drawn. If set to 0, the maximum-likelihood estimate of the (finite) sample's variance is computed. Other values can be used for special use cases.

verbose name
Degrees Of Freedom To Subtract
default value
0
port type
IntPort
value type
int (can be None)

ignore_nans

If activated the channels containing nan values are ignored.

verbose name
Ignore Channels With Nan Values
default value
False
port type
BoolPort
value type
bool (can be None)

set_breakpoint

Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.

verbose name
Set Breakpoint (Debug Only)
default value
False
port type
BoolPort
value type
bool (can be None)

metadata

User-definable meta-data associated with the node. Usually reserved for technical purposes.

verbose name
Metadata
default value
{}
port type
DictPort
value type
dict (can be None)

recurse_lists

Whether to treat lists as a recursive data structure as opposed to a numeric array. When disabled, lists are treated like arrays; they are expected to contain numbers or regularly shaped sublists of numbers and are subject to the conventional broadcasting rules of arrays known from numpy and similar libraries. When this option is enabled, lists may instead contain non-numeric data structures such as packets, dictionaries, tuples, or lists of non-uniform shapes, and will in turn not be subject to normal array broadcasting rules. Processing lists of numbers this way involves more overhead than when this option is set to False. Note that dictionaries and tuples are always treated as recursive data structures by this node.

verbose name
Lists As Data Structure
default value
False
port type
BoolPort
value type
bool (can be None)