Top Description Fields Constructors Methods
org.apache.commons.math3.stat.descriptive.rank

public Class Median

extends Percentile
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
java.io.Serializable, org.apache.commons.math3.exception.MathIllegalArgumentException, .NullArgumentException, org.apache.commons.math3.stat.ranking.NaNStrategy, org.apache.commons.math3.util.KthSelector

Returns the median of the available values. This is the same as the 50th percentile. See Percentile for a description of the algorithm used.

Note that this implementation is not synchronized. If multiple threads access an instance of this class concurrently, and at least one of the threads invokes the increment() or clear() method, it must be synchronized externally.

Field Summary

Modifier and TypeField and Description
private static final double
FIXED_QUANTILE_50

Fixed quantile.

private static final long

Constructor Summary

AccessConstructor and Description
public
Median()

Default constructor.

public
Median(Median
the Median instance to copy
original
)

Copy constructor, creates a new Median identical to the original

private
Median(final Percentile.EstimationType
one of the percentile estimation types
estimationType
,
final NaNStrategy
one of NaNStrategy to handle with NaNs
nanStrategy
,
final KthSelector
KthSelector to use for pivoting during search
kthSelector
)

Constructs a Median with the specific EstimationType, NaNStrategy and PivotingStrategy.

Method Summary

Modifier and TypeMethod and Description
public Median
withEstimationType(final Percentile.EstimationType
estimation type for the new instance
newEstimationType
)

Overrides org.apache.commons.math3.stat.descriptive.rank.Percentile.withEstimationType.

Build a new instance similar to the current one except for the estimation type.

public Median
withKthSelector(final KthSelector
KthSelector for the new instance
newKthSelector
)

Overrides org.apache.commons.math3.stat.descriptive.rank.Percentile.withKthSelector.

Build a new instance similar to the current one except for the kthSelector instance specifically set.

public Median
withNaNStrategy(final NaNStrategy
NaN strategy for the new instance
newNaNStrategy
)

Overrides org.apache.commons.math3.stat.descriptive.rank.Percentile.withNaNStrategy.

Build a new instance similar to the current one except for the NaN handling strategy.

Inherited from org.apache.commons.math3.stat.descriptive.rank.Percentile:
copycopyevaluateevaluateevaluateevaluategetEstimationTypegetKthSelectorgetNaNStrategygetPivotingStrategygetQuantilegetWorkArraymedianOf3setDatasetDatasetQuantile

Field Detail

FIXED_QUANTILE_50back to summary
private static final double FIXED_QUANTILE_50

Fixed quantile.

serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.apache.commons.math3.stat.descriptive.rank.Percentile.serialVersionUID.

Serializable version identifier

Constructor Detail

Medianback to summary
public Median()

Default constructor.

Medianback to summary
public Median(Median original) throws NullArgumentException

Copy constructor, creates a new Median identical to the original

Parameters
original:Median

the Median instance to copy

Exceptions
NullArgumentException:
if original is null
Medianback to summary
private Median(final Percentile.EstimationType estimationType, final NaNStrategy nanStrategy, final KthSelector kthSelector) throws MathIllegalArgumentException

Constructs a Median with the specific EstimationType, NaNStrategy and PivotingStrategy.

Parameters
estimationType:Percentile.EstimationType

one of the percentile estimation types

nanStrategy:NaNStrategy

one of NaNStrategy to handle with NaNs

kthSelector:KthSelector

KthSelector to use for pivoting during search

Exceptions
MathIllegalArgumentException:
if p is not within (0,100]
NullArgumentException:
if type or NaNStrategy passed is null

Method Detail

withEstimationTypeback to summary
public Median withEstimationType(final Percentile.EstimationType newEstimationType)

Overrides org.apache.commons.math3.stat.descriptive.rank.Percentile.withEstimationType.

Doc from org.apache.commons.math3.stat.descriptive.rank.Percentile.withEstimationType.

Build a new instance similar to the current one except for the estimation type.

This method is intended to be used as part of a fluent-type builder pattern. Building finely tune instances should be done as follows:

  Percentile customized = new Percentile(quantile).
                          withEstimationType(estimationType).
                          withNaNStrategy(nanStrategy).
                          withKthSelector(kthSelector);

If any of the withXxx method is omitted, the default value for the corresponding customization parameter will be used.

Parameters
newEstimationType:Percentile.EstimationType

estimation type for the new instance

Returns:Median

a new instance, with changed estimation type

Annotations
@Override
withKthSelectorback to summary
public Median withKthSelector(final KthSelector newKthSelector)

Overrides org.apache.commons.math3.stat.descriptive.rank.Percentile.withKthSelector.

Doc from org.apache.commons.math3.stat.descriptive.rank.Percentile.withKthSelector.

Build a new instance similar to the current one except for the kthSelector instance specifically set.

This method is intended to be used as part of a fluent-type builder pattern. Building finely tune instances should be done as follows:

  Percentile customized = new Percentile(quantile).
                          withEstimationType(estimationType).
                          withNaNStrategy(nanStrategy).
                          withKthSelector(newKthSelector);

If any of the withXxx method is omitted, the default value for the corresponding customization parameter will be used.

Parameters
newKthSelector:KthSelector

KthSelector for the new instance

Returns:Median

a new instance, with changed KthSelector

Annotations
@Override
withNaNStrategyback to summary
public Median withNaNStrategy(final NaNStrategy newNaNStrategy)

Overrides org.apache.commons.math3.stat.descriptive.rank.Percentile.withNaNStrategy.

Doc from org.apache.commons.math3.stat.descriptive.rank.Percentile.withNaNStrategy.

Build a new instance similar to the current one except for the NaN handling strategy.

This method is intended to be used as part of a fluent-type builder pattern. Building finely tune instances should be done as follows:

  Percentile customized = new Percentile(quantile).
                          withEstimationType(estimationType).
                          withNaNStrategy(nanStrategy).
                          withKthSelector(kthSelector);

If any of the withXxx method is omitted, the default value for the corresponding customization parameter will be used.

Parameters
newNaNStrategy:NaNStrategy

NaN strategy for the new instance

Returns:Median

a new instance, with changed NaN handling strategy

Annotations
@Override