Class SemiVariance

  • All Implemented Interfaces:
    MathArrays.Function, UnivariateStatistic

    public class SemiVariance
    extends AbstractUnivariateStatistic

    Computes the semivariance of a set of values with respect to a given cutoff value. We define the downside semivariance of a set of values x against the cutoff value cutoff to be
    Σ (x[i] - target)2 / df
    where the sum is taken over all i such that x[i] < cutoff and df is the length of x (non-bias-corrected) or one less than this number (bias corrected). The upside semivariance is defined similarly, with the sum taken over values of x that exceed the cutoff value.

    The cutoff value defaults to the mean, bias correction defaults to true and the "variance direction" (upside or downside) defaults to downside. The variance direction and bias correction may be set using property setters or their values can provided as parameters to evaluate(double[], double, Direction, boolean, int, int).

    If the input array is null, evaluate methods throw IllegalArgumentException. If the array has length 1, 0 is returned, regardless of the value of the cutoff.

    Note that this class is not intended to be threadsafe. If multiple threads access an instance of this class concurrently, and one or more of these threads invoke property setters, external synchronization must be provided to ensure correct results.

    Since:
    2.1
    • Field Detail

      • UPSIDE_VARIANCE

        public static final SemiVariance.Direction UPSIDE_VARIANCE
        The UPSIDE Direction is used to specify that the observations above the cutoff point will be used to calculate SemiVariance.
      • DOWNSIDE_VARIANCE

        public static final SemiVariance.Direction DOWNSIDE_VARIANCE
        The DOWNSIDE Direction is used to specify that the observations below. the cutoff point will be used to calculate SemiVariance
    • Constructor Detail

      • SemiVariance

        public SemiVariance()
        Constructs a SemiVariance with default (true) biasCorrected property and default (Downside) varianceDirection property.
      • SemiVariance

        public SemiVariance​(boolean biasCorrected)
        Constructs a SemiVariance with the specified biasCorrected property and default (Downside) varianceDirection property.
        Parameters:
        biasCorrected - setting for bias correction - true means bias will be corrected and is equivalent to using the "no arg" constructor
      • SemiVariance

        public SemiVariance​(SemiVariance.Direction direction)
        Constructs a SemiVariance with the specified Direction property. and default (true) biasCorrected property
        Parameters:
        direction - setting for the direction of the SemiVariance to calculate
      • SemiVariance

        public SemiVariance​(boolean corrected,
                            SemiVariance.Direction direction)
        Constructs a SemiVariance with the specified isBiasCorrected property and the specified Direction property.
        Parameters:
        corrected - setting for bias correction - true means bias will be corrected and is equivalent to using the "no arg" constructor
        direction - setting for the direction of the SemiVariance to calculate