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.
| Modifier and Type | Class and Description |
|---|---|
| public static enum | SemiVariance.
The direction of the semivariance - either upside or downside. |
| Modifier and Type | Field and Description |
|---|---|
| private boolean | biasCorrected
Determines whether or not bias correction is applied when computing the value of the statisic. |
| public static final SemiVariance. | DOWNSIDE_VARIANCE
The DOWNSIDE Direction is used to specify that the observations below the cutoff point will be used to calculate SemiVariance |
| private static final long | serialVersionUID
Serializable version identifier |
| public static final SemiVariance. | UPSIDE_VARIANCE
The UPSIDE Direction is used to specify that the observations above the cutoff point will be used to calculate SemiVariance. |
| private SemiVariance. | varianceDirection
Determines whether to calculate downside or upside SemiVariance. |
| Access | Constructor and Description |
|---|---|
| public | SemiVariance()
Constructs a SemiVariance with default (true) |
| public | SemiVariance(final boolean
setting for bias correction - true means
bias will be corrected and is equivalent to using the argumentless
constructor biasCorrected)Constructs a SemiVariance with the specified |
| public | SemiVariance(final SemiVariance.
setting for the direction of the SemiVariance
to calculate directionConstructs a SemiVariance with the specified |
| public | SemiVariance(final boolean
setting for bias correction - true means
bias will be corrected and is equivalent to using the argumentless
constructor corrected, final SemiVariance.setting for the direction of the SemiVariance
to calculate directionConstructs a SemiVariance with the specified |
| public | SemiVariance(final SemiVariance
the original)SemiVariance instance to copyCopy constructor, creates a new |
| Modifier and Type | Method and Description |
|---|---|
| public SemiVariance | copy()
Implements abstract org. Implements org. Returns a copy of the statistic with the same internal state. |
| public static void | copy(final SemiVariance
SemiVariance to copy source, SemiVariance SemiVariance to copy to dest)Copies source to dest. |
| public double | Returns: the SemiVariancethe input array values, final int index of the first array element to include start, final int the number of elements to include length)Implements abstract org. Implements org. Returns the |
| public double | Returns: the SemiVariancethe input array values, SemiVariance.the directionDirection of the semivarianceThis method calculates |
| public double | Returns: the SemiVariancethe input array values, final double the reference point cutoff)Returns the |
| public double | Returns: the SemiVariancethe input array values, final double the reference point cutoff, final SemiVariance.the directionDirection of the semivarianceReturns the |
| public double | Returns: the SemiVariancethe input array values, final double the reference point cutoff, final SemiVariance.the direction,Direction of the semivariancethe BiasCorrection flag corrected, final int index of the first array element to include start, final int the number of elements to include length)Returns the |
| public SemiVariance. | |
| public boolean | Returns: the value of biasCorrected.Returns true iff biasCorrected property is set to true. |
| public void | setBiasCorrected(boolean
new biasCorrected property value biasCorrected)Sets the biasCorrected property. |
| public void | setVarianceDirection(SemiVariance.
the direction of the semivariance varianceDirectionSets the variance direction |
| biasCorrected | back to summary |
|---|---|
| private boolean biasCorrected Determines whether or not bias correction is applied when computing the value of the statisic. True means that bias is corrected. | |
| DOWNSIDE_VARIANCE | back to summary |
|---|---|
| public static final SemiVariance. The DOWNSIDE Direction is used to specify that the observations below the cutoff point will be used to calculate SemiVariance | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Serializable version identifier | |
| UPSIDE_VARIANCE | back to summary |
|---|---|
| public static final SemiVariance. The UPSIDE Direction is used to specify that the observations above the cutoff point will be used to calculate SemiVariance. | |
| varianceDirection | back to summary |
|---|---|
| private SemiVariance. Determines whether to calculate downside or upside SemiVariance. | |
| SemiVariance | back to summary |
|---|---|
| public SemiVariance() Constructs a SemiVariance with default (true) | |
| SemiVariance | back to summary |
|---|---|
| public SemiVariance(final boolean biasCorrected) Constructs a SemiVariance with the specified
| |
| SemiVariance | back to summary |
|---|---|
| public SemiVariance(final SemiVariance. Constructs a SemiVariance with the specified
| |
| SemiVariance | back to summary |
|---|---|
| public SemiVariance(final boolean corrected, final SemiVariance. Constructs a SemiVariance with the specified
| |
| SemiVariance | back to summary |
|---|---|
| public SemiVariance(final SemiVariance original) throws NullArgumentException Copy constructor, creates a new
| |
| copy | back to summary |
|---|---|
| public SemiVariance copy() Implements abstract org. Implements org. Doc from org. Returns a copy of the statistic with the same internal state.
| |
| copy | back to summary |
|---|---|
| public static void copy(final SemiVariance source, SemiVariance dest) throws NullArgumentException Copies source to dest. Neither source nor dest can be null.
| |
| evaluate | back to summary |
|---|---|
| public double evaluate(final double[] values, final int start, final int length) throws MathIllegalArgumentException Implements abstract org. Implements org. Returns the Returns
| |
| evaluate | back to summary |
|---|---|
| public double evaluate(final double[] values, SemiVariance. This method calculates
| |
| evaluate | back to summary |
|---|---|
| public double evaluate(final double[] values, final double cutoff) throws MathIllegalArgumentException Returns the Returns
| |
| evaluate | back to summary |
|---|---|
| public double evaluate(final double[] values, final double cutoff, final SemiVariance. Returns the Returns
| |
| evaluate | back to summary |
|---|---|
| public double evaluate(final double[] values, final double cutoff, final SemiVariance. Returns the Returns
| |
| getVarianceDirection | back to summary |
|---|---|
| public SemiVariance. Returns the varianceDirection property.
| |
| isBiasCorrected | back to summary |
|---|---|
| public boolean isBiasCorrected() Returns true iff biasCorrected property is set to true.
| |
| setBiasCorrected | back to summary |
|---|---|
| public void setBiasCorrected(boolean biasCorrected) Sets the biasCorrected property.
| |
| setVarianceDirection | back to summary |
|---|---|
| public void setVarianceDirection(SemiVariance. Sets the variance direction
| |
| Modifier and Type | Field and Description |
|---|---|
| private boolean | direction
boolean value UPSIDE <-> true |
| public static final SemiVariance. | DOWNSIDE
The DOWNSIDE Direction is used to specify that the observations below the cutoff point will be used to calculate SemiVariance |
| public static final SemiVariance. | UPSIDE
The UPSIDE Direction is used to specify that the observations above the cutoff point will be used to calculate SemiVariance |
| Access | Constructor and Description |
|---|---|
| private | Direction(boolean
boolean value representing the Direction. True corresponds to UPSIDE. b)Create a Direction with the given value. |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv boolean | Returns: true if direction is UPSIDE; false otherwiseReturns the value of this Direction. |
| public static SemiVariance. | |
| public static SemiVariance. |
| direction | back to summary |
|---|---|
| private boolean direction boolean value UPSIDE <-> true | |
| DOWNSIDE | back to summary |
|---|---|
| public static final SemiVariance. The DOWNSIDE Direction is used to specify that the observations below the cutoff point will be used to calculate SemiVariance | |
| UPSIDE | back to summary |
|---|---|
| public static final SemiVariance. The UPSIDE Direction is used to specify that the observations above the cutoff point will be used to calculate SemiVariance | |
| Direction | back to summary |
|---|---|
| private Direction(boolean b) Create a Direction with the given value.
| |
| getDirection | back to summary |
|---|---|
| pack-priv boolean getDirection() Returns the value of this Direction. True corresponds to UPSIDE.
| |
| valueOf | back to summary |
|---|---|
| public static SemiVariance. | |
| values | back to summary |
|---|---|
| public static SemiVariance. | |