PCL
Statistical Functions

## Classes

struct  pcl::TwoSidedEstimate
Two-sided descriptive statistical estimate. More...

## Functions

template<typename T >
double pcl::AvgDev (const T *i, const T *j, double center)

template<typename T >
double pcl::AvgDev (const T *i, const T *j)

template<typename T >
double pcl::BendMidvariance (const T *x, const T *xn, double center, double beta=0.2)

template<typename T >
double pcl::BiweightMidvariance (const T *x, const T *xn, double center, double sigma, int k=9, bool reducedLength=false)

template<typename T >
double pcl::MAD (const T *i, const T *j, double center)

template<typename T >
double pcl::MAD (const T *i, const T *j)

template<typename T >
double pcl::Mean (const T *i, const T *j)

template<class T >
double pcl::Median (const T *i, const T *j)

template<typename T >
double pcl::MedianDestructive (T *i, T *j)

template<typename T , class BP >
double pcl::MedianDestructive (T *i, T *j, BP p)

template<typename T >
double pcl::Modulus (const T *i, const T *j)

template<typename T >
double pcl::OrderStatistic (const T *i, const T *j, distance_type k)

template<typename T >
double pcl::OrderStatisticDestructive (T *i, T *j, distance_type k)

template<typename T , class BP >
double pcl::OrderStatisticDestructive (const T *i, const T *j, distance_type k, BP p)

template<typename T >
TwoSidedEstimate pcl::Pow (const TwoSidedEstimate &e, T x)

template<typename T >
double pcl::Qn (T *x, T *xn)

template<typename T >
double pcl::Sn (T *x, T *xn)

TwoSidedEstimate pcl::Sqrt (const TwoSidedEstimate &e)

template<typename T >
double pcl::StableAvgDev (const T *i, const T *j, double center)

template<typename T >
double pcl::StableAvgDev (const T *i, const T *j)

template<typename T >
double pcl::StableMean (const T *i, const T *j)

template<typename T >
double pcl::StableModulus (const T *i, const T *j)

template<typename T >
double pcl::StableSum (const T *i, const T *j)

template<typename T >
double pcl::StableSumOfSquares (const T *i, const T *j)

template<typename T >
double pcl::StdDev (const T *i, const T *j, double center)

template<typename T >
double pcl::StdDev (const T *i, const T *j)

template<typename T >
double pcl::Sum (const T *i, const T *j)

template<typename T >
double pcl::SumOfSquares (const T *i, const T *j)

template<typename T >
double pcl::TrimmedMean (const T *i, const T *j, distance_type l=1, distance_type h=1)

template<typename T >
double pcl::TrimmedMeanDestructive (T *i, T *j, distance_type l=1, distance_type h=1)

template<typename T >
double pcl::TrimmedMeanOfSquares (const T *i, const T *j, distance_type l=1, distance_type h=1)

template<typename T >
double pcl::TrimmedMeanOfSquaresDestructive (T *i, T *j, distance_type l=1, distance_type h=1)

template<typename T >
TwoSidedEstimate pcl::TwoSidedAvgDev (const T *i, const T *j, double center)

template<typename T >
TwoSidedEstimate pcl::TwoSidedAvgDev (const T *i, const T *j)

template<typename T >
TwoSidedEstimate pcl::TwoSidedBiweightMidvariance (const T *x, const T *xn, double center, const TwoSidedEstimate &sigma, int k=9, bool reducedLength=false)

template<typename T >
TwoSidedEstimate pcl::TwoSidedMAD (const T *i, const T *j, double center)

template<typename T >
TwoSidedEstimate pcl::TwoSidedMAD (const T *i, const T *j)

template<typename T >
double pcl::Variance (const T *i, const T *j, double center)

template<typename T >
double pcl::Variance (const T *i, const T *j)

## ◆ AvgDev() [1/2]

template<typename T >
 double pcl::AvgDev ( const T * i, const T * j, double center )
inline

Returns the average absolute deviation of the values in a sequence [i,j) with respect to the specified center value.

When the median of the sequence is used as the center value, this function returns the average absolute deviation from the median, which is a well-known estimator of dispersion.

For sequences of less than two elements, this function returns zero.

See the remarks made for the Sum() function, which are equally applicable in this case. See StableAvgDev() for a (slow) numerically stable version of this function.

Note
To make the average absolute deviation about the median consistent with the standard deviation of a normal distribution, it must be multiplied by the constant 1.2533.

Definition at line 3139 of file Math.h.

## ◆ AvgDev() [2/2]

template<typename T >
 double pcl::AvgDev ( const T * i, const T * j )
inline

Returns the average absolute deviation from the median of the values in a sequence [i,j).

The average absolute deviation from the median is a well-known estimator of dispersion.

For sequences of less than two elements, this function returns zero.

See the remarks made for the Sum() function, which are equally applicable in this case. See StableAvgDev() for a (slow) numerically stable version of this function.

Note
To make the average absolute deviation about the median consistent with the standard deviation of a normal distribution, it must be multiplied by the constant 1.2533.

Definition at line 3208 of file Math.h.

## ◆ BendMidvariance()

template<typename T >
 double pcl::BendMidvariance ( const T * x, const T * xn, double center, double beta = `0.2` )

Returns a percentage bend midvariance (PBMV) for the elements in a sequence [x,xn).

Parameters
 x,xn Define a sequence of sample data points for which the PBWV estimator will be calculated. center Reference center value. Normally, the median of the sample should be used. beta Rejection parameter in the [0,0.5] range. Higher values improve robustness to outliers (i.e., increase the breakdown point of the estimator) at the expense of a lower efficiency. The default value is beta=0.2.

The square root of the percentage bend midvariance is a robust estimator of scale. With the default beta=0.2, its Gaussian efficiency is 67%. With beta=0.1, its efficiency is 85% but its breakdown is only 0.1.

For sequences of less than two elements, this function returns zero.

References

Rand R. Wilcox (2012), Introduction to Robust Estimation and Hypothesis Testing, 3rd Edition, Elsevier Inc., Section 3.12.3.

Definition at line 4203 of file Math.h.

## ◆ BiweightMidvariance()

template<typename T >
 double pcl::BiweightMidvariance ( const T * x, const T * xn, double center, double sigma, int k = `9`, bool reducedLength = `false` )

Returns a biweight midvariance (BWMV) for the elements in a sequence [x,xn).

Parameters
 x,xn Define a sequence of sample data points for which the BWMV estimator will be calculated. center Reference center value. Normally, the median of the sample should be used. sigma A reference estimate of dispersion. Normally, the median absolute deviation from the median (MAD) of the sample should be used. k Rejection limit in sigma units. The default value is k=9. reducedLength If true, reduce the sample size to exclude rejected elements. This tends to approximate the true dispersion of the data more accurately for relatively small samples, or samples with large amounts of outliers. Note that this departs from the standard definition of biweight midvariance, where the total number of data items is used to scale the variance estimate. If false, use the full sample size, including rejected elements, which gives a standard biweight midvariance estimate.

The square root of the biweight midvariance is a robust estimator of scale. It is an efficient estimator with respect to many statistical distributions (about 87% Gaussian efficiency), and appears to have a breakdown point close to 0.5 (the same as MAD).

For sequences of less than two elements, this function returns zero.

Note
To make the BWMV estimator consistent with the standard deviation of a normal distribution, its square root must be multiplied by the constant 0.991.

References

Rand R. Wilcox (2017), Introduction to Robust Estimation and Hypothesis Testing, 4th Edition, Elsevier Inc., Section 3.12.1.

Definition at line 4064 of file Math.h.

template<typename T >
 double pcl::MAD ( const T * i, const T * j, double center )
inline

Returns the median absolute deviation (MAD) of the values in a sequence [i,j) with respect to the specified center value.

The MAD is a well-known robust estimator of scale.

For sequences of less than two elements, this function returns zero.

Note
To make the MAD estimator consistent with the standard deviation of a normal distribution, its result must be multiplied by the constant 1.4826.

Definition at line 3496 of file Math.h.

template<typename T >
 double pcl::MAD ( const T * i, const T * j )
inline

Returns the median absolute deviation from the median (MAD) for the values in a sequence [i,j).

The MAD is a well-known robust estimator of scale.

For sequences of less than two elements, this function returns zero.

Note
To make the MAD estimator consistent with the standard deviation of a normal distribution, its result must be multiplied by the constant 1.4826.

Definition at line 3539 of file Math.h.

## ◆ Mean()

template<typename T >
 double pcl::Mean ( const T * i, const T * j )
inline

Returns the arithmetic mean of a sequence [i,j).

For empty sequences, this function returns zero.

See the remarks made for the Sum() function, which are equally applicable in this case. See StableMean() for a (slow) numerically stable version of this function.

Definition at line 2444 of file Math.h.

## ◆ Median()

template<class T >
 double pcl::Median ( const T * i, const T * j )
inline

Returns the median value of a sequence [i,j).

For scalar data types the following algorithms are used:

• Hard-coded, fast selection networks for small sequences of 32 or less elements.
• A quick selection algorithm for sequences of up to about 2M elements. The actual limit has been determined empirically and can vary across PCL versions. This single-threaded algorithm can use up to 16 MiB of additional memory allocated dynamically (for 8-byte types such as `double`).
• A parallelized, fast histogram-based algorithm for sequences larger than the limit described above. This algorithm has negligible additional memory space requirements.

For non-scalar data types, this function requires the following type conversion operator publicly defined for the type T:

T::operator double() const;

This operator will be used to generate a temporary dynamic array of `double` values with the length of the input sequence, which will be used to compute the median with the algorithms enumerated above.

References (selection networks)

• Knuth, D. E., The Art of Computer Programming, volume 3: Sorting and Searching, Addison Wesley, 1973.
• Hillis, W. D., Co-evolving parasites improve simulated evolution as an optimization procedure. Langton, C. et al. (Eds.), Artificial Life II. Addison Wesley, 1992.
• Hugues Juille, Evolution of Non-Deterministic Incremental Algorithms as a New Approach for Search in State Spaces, 1995

References (quick select algorithm)

• William H. Press et al., Numerical Recipes 3rd Edition: The Art of Scientific Computing, Cambridge University Press, 2007, Section 8.5.
• Robert Sedgewick, Kevin Wayne, Algorithms, 4th Edition, Addison-Wesley Professional, 2011, pp 345-347.

Definition at line 2613 of file Math.h.

## ◆ MedianDestructive() [1/2]

template<typename T >
 double pcl::MedianDestructive ( T * i, T * j )
inline

Returns the median value of a sequence [i,j), altering the existing order of elements in the input sequence.

This function is intended for sequences of non-scalar objects where the order of elements is irrelevant, and hence generation of a working duplicate is unnecessary. The following type conversion operator must be publicly defined for the type T:

T::operator double() const;

The following algorithms are used:

• Hard-coded, fast selection networks for sequences of 9 or less elements.
• A quick selection algorithm for sequences larger than 9 elements.
Note
This is a destructive median calculation algorithm: it alters the existing order of items in the input [i,j) sequence.

References (selection networks)

• Knuth, D. E., The Art of Computer Programming, volume 3: Sorting and Searching, Addison Wesley, 1973.
• Hillis, W. D., Co-evolving parasites improve simulated evolution as an optimization procedure. Langton, C. et al. (Eds.), Artificial Life II. Addison Wesley, 1992.
• Hugues Juille, Evolution of Non-Deterministic Incremental Algorithms as a New Approach for Search in State Spaces, 1995

References (quick select algorithm)

• William H. Press et al., Numerical Recipes 3rd Edition: The Art of Scientific Computing, Cambridge University Press, 2007, Section 8.5.
• Robert Sedgewick, Kevin Wayne, Algorithms, 4th Edition, Addison-Wesley Professional, 2011, pp 345-347.

Definition at line 2695 of file Math.h.

## ◆ MedianDestructive() [2/2]

template<typename T , class BP >
 double pcl::MedianDestructive ( T * i, T * j, BP p )
inline

Returns the median value of a sequence [i,j), altering the existing order of elements in the input sequence.

Element comparison is given by a binary predicate p such that p( a, b ) is true for any pair a, b of elements such that a precedes b.

We use fast, hard-coded selection networks for sequences of 9 or less elements, and a quick selection algorithm for larger sets.

See the documentation of MedianDestructive( T*, T* ) for more information and references.

Definition at line 2776 of file Math.h.

## ◆ Modulus()

template<typename T >
 double pcl::Modulus ( const T * i, const T * j )
inline

Returns the sum of the absolute values of the elements in a sequence [i,j).

For empty sequences, this function returns zero.

See the remarks made for the Sum() function, which are equally applicable in this case. See StableModulus() for a (slow) numerically stable version of this function.

Definition at line 2352 of file Math.h.

## ◆ OrderStatistic()

template<typename T >
 double pcl::OrderStatistic ( const T * i, const T * j, distance_type k )
inline

Returns the k-th order statistic of a sequence [i,j).

For scalar data types the following algorithms are used:

• A quick selection algorithm for sequences of up to about 2M elements. The actual limit has been determined empirically and can vary across PCL versions. This single-threaded algorithm can use up to 16 MiB of additional memory allocated dynamically (for 8-byte types such as `double`).
• A parallelized, fast histogram-based algorithm for sequences larger than the limit described above. This algorithm has negligible additional memory space requirements.

For non-scalar data types, this function requires the following type conversion operator publicly defined for the type T:

T::operator double() const;

This operator will be used to generate a temporary dynamic array of `double` values with the length of the input sequence, which will be used to compute the median with the quick selection algorithm.

References (quick select algorithm)

• William H. Press et al., Numerical Recipes 3rd Edition: The Art of Scientific Computing, Cambridge University Press, 2007, Section 8.5.
• Robert Sedgewick, Kevin Wayne, Algorithms, 4th Edition, Addison-Wesley Professional, 2011, pp 345-347.

Definition at line 2873 of file Math.h.

## ◆ OrderStatisticDestructive() [1/2]

template<typename T >
 double pcl::OrderStatisticDestructive ( T * i, T * j, distance_type k )
inline

Returns the k-th order statistic of a sequence [i,j), altering the existing order of elements in the input sequence.

This function is intended for sequences of non-scalar objects where the order of elements is irrelevant, and hence generation of a working duplicate is unnecessary. The following type conversion operator must be publicly defined for the type T:

<

> T::operator double() const;

The quick selection algorithm is used to find the k-th element in the ordered sequence.

Note
This is a destructive algorithm: it alters the existing order of items in the input [i,j) sequence.

References (quick select algorithm)

• William H. Press et al., Numerical Recipes 3rd Edition: The Art of Scientific Computing, Cambridge University Press, 2007, Section 8.5.
• Robert Sedgewick, Kevin Wayne, Algorithms, 4th Edition, Addison-Wesley Professional, 2011, pp 345-347.

Definition at line 2932 of file Math.h.

## ◆ OrderStatisticDestructive() [2/2]

template<typename T , class BP >
 double pcl::OrderStatisticDestructive ( const T * i, const T * j, distance_type k, BP p )
inline

Returns the k-th order statistic of a sequence [i,j), altering the existing order of elements in the input sequence.

Element comparison is given by a binary predicate p such that p( a, b ) is true for any pair a, b of elements such that a precedes b.

See the documentation of OrderStatisticDestructive( T*, T*, distance_type ) for more information and references.

Definition at line 2954 of file Math.h.

## ◆ Pow()

template<typename T >
 TwoSidedEstimate pcl::Pow ( const TwoSidedEstimate & e, T x )
inline

Returns the component wise square root of a two-sided estimate.

Definition at line 3411 of file Math.h.

## ◆ Qn()

template<typename T >
 double pcl::Qn ( T * x, T * xn )

Returns the Qn scale estimator of Rousseeuw and Croux for a sequence [x,xn):

```Qn = c * first_quartile( |x_i - x_j| : i < j )
```

where first_quartile() is the order statistic of rank (n + 1)/4. n >= 2 is the number of elements in the sequence: n = xn - x.

This implementation is a C++ translation of the original FORTRAN code by the authors (see References). The algorithm has O(n*log_2(n)) time complexity and the implementation requires about O(9*n) additional storage.

The constant c = 2.2219 must be used to make the Qn estimator converge to the standard deviation of a pure normal distribution. However, this implementation does not apply it (it uses c=1 implicitly), for consistency with other implementations of scale estimators.

References

P.J. Rousseeuw and C. Croux (1993), Alternatives to the Median Absolute Deviation, Journal of the American Statistical Association, Vol. 88, pp. 1273-1283.

Note
This is a destructive algorithm: it may alter the initial order of items in the specified [x,xn) sequence.

Definition at line 3893 of file Math.h.

Referenced by pcl::GenericVector< sample *>::Qn().

## ◆ Sn()

template<typename T >
 double pcl::Sn ( T * x, T * xn )

Returns the Sn scale estimator of Rousseeuw and Croux for a sequence [x,xn):

```Sn = c * low_median( high_median( |x_i - x_j| ) )
```

where low_median() is the order statistic of rank (n + 1)/2, and high_median() is the order statistic of rank n/2 + 1. n >= 2 is the number of elements in the sequence: n = xn - x.

This implementation is a direct C++ translation of the original FORTRAN code by the authors (see References). The algorithm has O(n*log_2(n)) time complexity and uses O(n) additional storage.

The constant c = 1.1926 must be used to make the Sn estimator converge to the standard deviation of a pure normal distribution. However, this implementation does not apply it (it uses c=1 implicitly), for consistency with other implementations of scale estimators.

References

P.J. Rousseeuw and C. Croux (1993), Alternatives to the Median Absolute Deviation, Journal of the American Statistical Association, Vol. 88, pp. 1273-1283.

Note
This is a destructive algorithm: it may alter the initial order of items in the specified [x,xn) sequence.

Definition at line 3644 of file Math.h.

Referenced by pcl::GenericVector< sample *>::Sn().

## ◆ Sqrt()

 TwoSidedEstimate pcl::Sqrt ( const TwoSidedEstimate & e )
inline

Returns the component wise square root of a two-sided estimate.

Definition at line 3402 of file Math.h.

References pcl::TwoSidedEstimate::high, pcl::TwoSidedEstimate::low, and pcl::Sqrt().

## ◆ StableAvgDev() [1/2]

template<typename T >
 double pcl::StableAvgDev ( const T * i, const T * j, double center )
inline

Returns the average absolute deviation of the values in a sequence [i,j) with respect to the specified center value, using a numerically stable summation algorithm to minimize roundoff error.

When the median of the sequence is used as the center value, this function returns the average absolute deviation from the median, which is a well-known estimator of dispersion.

For sequences of less than two elements, this function returns zero.

In the current PCL versions, this function implements the Kahan summation algorithm to reduce roundoff error to the machine's floating point error.

Note
To make the average absolute deviation about the median consistent with the standard deviation of a normal distribution, it must be multiplied by the constant 1.2533.

Definition at line 3171 of file Math.h.

## ◆ StableAvgDev() [2/2]

template<typename T >
 double pcl::StableAvgDev ( const T * i, const T * j )
inline

Computes the average absolute deviation from the median of the values in a sequence [i,j) using a numerically stable summation algorithm to minimize roundoff error.

The average absolute deviation from the median is a well-known estimator of dispersion.

For sequences of less than two elements, this function returns zero.

In the current PCL versions, this function implements the Kahan summation algorithm to reduce roundoff error to the machine's floating point error.

Note
To make the average absolute deviation about the median consistent with the standard deviation of a normal distribution, it must be multiplied by the constant 1.2533.

Definition at line 3240 of file Math.h.

## ◆ StableMean()

template<typename T >
 double pcl::StableMean ( const T * i, const T * j )
inline

Computes the arithmetic mean of a sequence [i,j) using a numerically stable summation algorithm to minimize roundoff error.

For empty sequences, this function returns zero.

In the current PCL versions, this function implements the Kahan summation algorithm to reduce roundoff error to the machine's floating point error.

Definition at line 2463 of file Math.h.

## ◆ StableModulus()

template<typename T >
 double pcl::StableModulus ( const T * i, const T * j )
inline

Computes the sum of the absolute values of the elements in a sequence [i,j) using a numerically stable summation algorithm to minimize roundoff error.

For empty sequences, this function returns zero.

In the current PCL versions, this function implements the Kahan summation algorithm to reduce roundoff error to the machine's floating point error.

Definition at line 2371 of file Math.h.

## ◆ StableSum()

template<typename T >
 double pcl::StableSum ( const T * i, const T * j )
inline

Computes the sum of elements in a sequence [i,j) using a numerically stable summation algorithm to minimize roundoff error.

For empty sequences, this function returns zero.

In the current PCL versions, this function implements the Kahan summation algorithm to reduce roundoff error to the machine's floating point error.

Definition at line 2327 of file Math.h.

## ◆ StableSumOfSquares()

template<typename T >
 double pcl::StableSumOfSquares ( const T * i, const T * j )
inline

Computes the sum of the squares of the elements in a sequence [i,j) using a numerically stable summation algorithm to minimize roundoff error.

For empty sequences, this function returns zero.

In the current PCL versions, this function implements the Kahan summation algorithm to reduce roundoff error to the machine's floating point error.

Definition at line 2418 of file Math.h.

## ◆ StdDev() [1/2]

template<typename T >
 double pcl::StdDev ( const T * i, const T * j, double center )
inline

Returns the standard deviation of a sequence [i,j) with respect to the specified center value.

For sequences of less than two elements, this function returns zero.

Definition at line 2548 of file Math.h.

## ◆ StdDev() [2/2]

template<typename T >
 double pcl::StdDev ( const T * i, const T * j )
inline

Returns the standard deviation from the mean of a sequence [i,j).

For sequences of less than two elements, this function returns zero.

Definition at line 2560 of file Math.h.

## ◆ Sum()

template<typename T >
 double pcl::Sum ( const T * i, const T * j )
inline

Returns the sum of elements in a sequence [i,j).

For empty sequences, this function returns zero.

This is a straight implementation of a floating point sum, which is subject to severe roundoff errors if the number of summed elements is large. One way to improve on this problem is to sort the input set by decreasing order of absolute value before calling this function. A much better solution, but computationally expensive, is a compensated summation algorithm such as Kahan summation, which we have implemented in the StableSum() routine.

Definition at line 2308 of file Math.h.

## ◆ SumOfSquares()

template<typename T >
 double pcl::SumOfSquares ( const T * i, const T * j )
inline

Returns the sum of the squares of the elements in a sequence [i,j).

For empty sequences, this function returns zero.

See the remarks made for the Sum() function, which are equally applicable in this case. See StableSumOfSquares() for a (slow) numerically stable version of this function.

Definition at line 2396 of file Math.h.

## ◆ TrimmedMean()

template<typename T >
 double pcl::TrimmedMean ( const T * i, const T * j, distance_type l = `1`, distance_type h = `1` )
inline

Computes the two-sided, asymmetric trimmed mean of a sequence [i,j).

The returned value is the arithmetic mean of a sequence [I+l,J-h-1], where [I,J) is the input sequence [i,j) sorted in ascending order.

Let n = j-i be the length of the input sequence. For empty sequences (n ≤ 0) or completely truncated sequences (l+h >= n), this function returns zero. Otherwise the returned value is the arithmetic mean of the nonrejected n-l-h elements in the sorted sequence, as described above.

Definition at line 2977 of file Math.h.

## ◆ TrimmedMeanDestructive()

template<typename T >
 double pcl::TrimmedMeanDestructive ( T * i, T * j, distance_type l = `1`, distance_type h = `1` )
inline

Computes the two-sided, asymmetric trimmed mean of a sequence [i,j), possibly altering the existing order of elements in the input sequence.

The returned value is the arithmetic mean of a sequence [I+l,J-h-1], where [I,J) represents the input sequence [i,j) sorted in ascending order.

Let n = j-i be the length of the input sequence. For empty sequences (n ≤ 0) or completely truncated sequences (l+h >= n), this function returns zero. Otherwise the returned value is the arithmetic mean of the nonrejected n-l-h elements in the sorted sequence, as described above.

Note
This is a destructive trimmed mean calculation algorithm: it may alter the existing order of items in the input [i,j) sequence.

Definition at line 3016 of file Math.h.

## ◆ TrimmedMeanOfSquares()

template<typename T >
 double pcl::TrimmedMeanOfSquares ( const T * i, const T * j, distance_type l = `1`, distance_type h = `1` )
inline

Computes the two-sided, asymmetric trimmed mean of squares of a sequence [i,j).

The returned value is the arithmetic mean of squares of a sequence [I+l,J-h-1], where [I,J) represents the input sequence [i,j) sorted in ascending order.

Let n = j-i be the length of the input sequence. For empty sequences (n ≤ 0) or completely truncated sequences (l+h >= n), this function returns zero. Otherwise the returned value is the arithmetic mean of the squared nonrejected n-l-h elements in the sorted sequence, as described above.

Definition at line 3054 of file Math.h.

## ◆ TrimmedMeanOfSquaresDestructive()

template<typename T >
 double pcl::TrimmedMeanOfSquaresDestructive ( T * i, T * j, distance_type l = `1`, distance_type h = `1` )
inline

Computes the two-sided, asymmetric trimmed mean of squares of a sequence [i,j), possibly altering the existing order of elements in the input sequence.

The returned value is the arithmetic mean of squares of a sequence [I+l,J-h-1], where [I,J) represents the input sequence [i,j) sorted in ascending order.

Let n = j-i be the length of the input sequence. For empty sequences (n ≤ 0) or completely truncated sequences (l+h >= n), this function returns zero. Otherwise the returned value is the arithmetic mean of the squared nonrejected n-l-h elements in the sorted sequence, as described above.

Note
This is a destructive trimmed mean of squares calculation algorithm: it may alter the existing order of items in the input [i,j) sequence.

Definition at line 3097 of file Math.h.

## ◆ TwoSidedAvgDev() [1/2]

template<typename T >
 TwoSidedEstimate pcl::TwoSidedAvgDev ( const T * i, const T * j, double center )
inline

Returns the two-sided average absolute deviation of the values in a sequence [i,j) with respect to the specified center value.

When the median of the sequence is used as the center value, this function returns the average absolute deviation from the median, which is a well-known estimator of dispersion.

For sequences of less than two elements, this function returns zero.

See the remarks made for the Sum() function, which are equally applicable in this case. See StableAvgDev() for a (slow) numerically stable version of this function.

Note
To make the average absolute deviation about the median consistent with the standard deviation of a normal distribution, it must be multiplied by the constant 1.2533.

Definition at line 3437 of file Math.h.

## ◆ TwoSidedAvgDev() [2/2]

template<typename T >
 TwoSidedEstimate pcl::TwoSidedAvgDev ( const T * i, const T * j )
inline

Returns the two-sided average absolute deviation from the median of the values in a sequence [i,j).

The average absolute deviation from the median is a well-known estimator of dispersion.

For sequences of less than two elements, this function returns zero.

See the remarks made for the Sum() function, which are equally applicable in this case. See StableAvgDev() for a (slow) numerically stable version of this function.

Note
To make the average absolute deviation about the median consistent with the standard deviation of a normal distribution, it must be multiplied by the constant 1.2533.

Definition at line 3478 of file Math.h.

## ◆ TwoSidedBiweightMidvariance()

template<typename T >
 TwoSidedEstimate pcl::TwoSidedBiweightMidvariance ( const T * x, const T * xn, double center, const TwoSidedEstimate & sigma, int k = `9`, bool reducedLength = `false` )

Returns a two-sided biweight midvariance (BWMV) for the elements in a sequence [x,xn).

Parameters
 x,xn Define a sequence of sample data points for which the two-sided BWMV estimator will be calculated. center Reference center value. Normally, the median of the sample should be used. sigma A reference two-sided estimate of dispersion. Normally, the two-sided median absolute deviation from the median (MAD) of the sample should be used. See the TwoSidedMAD() function. k Rejection limit in sigma units. The default value is k=9. reducedLength If true, reduce the sample size to exclude rejected elements. Size reduction is performed separately for the low and high halves of the data. This tends to approximate the true dispersion of the data more accurately for relatively small samples, or samples with large amounts of outliers. Note that this departs from the standard definition of biweight midvariance, where the total number of data items is used to scale the variance estimate. If false, use the full sample size, including rejected elements, which gives a standard biweight midvariance estimate.

Definition at line 4127 of file Math.h.

template<typename T >
 TwoSidedEstimate pcl::TwoSidedMAD ( const T * i, const T * j, double center )
inline

Returns the two-sided median absolute deviation (MAD) of the values in a sequence [i,j) with respect to the specified center value.

The MAD is a well-known robust estimator of scale.

For sequences of less than two elements, this function returns zero.

Note
To make the MAD estimator consistent with the standard deviation of a normal distribution, its result must be multiplied by the constant 1.4826.

Definition at line 3557 of file Math.h.

template<typename T >
 TwoSidedEstimate pcl::TwoSidedMAD ( const T * i, const T * j )
inline

Returns the two-sided median absolute deviation from the median (MAD) for the values in a sequence [i,j).

The MAD is a well-known robust estimator of scale.

For sequences of less than two elements, this function returns zero.

Note
To make the MAD estimator consistent with the standard deviation of a normal distribution, its result must be multiplied by the constant 1.4826.

Definition at line 3608 of file Math.h.

## ◆ Variance() [1/2]

template<typename T >
 double pcl::Variance ( const T * i, const T * j, double center )
inline

Returns the variance of a sequence [i,j) with respect to the specified center value.

For sequences of less than two elements, this function returns zero.

This implementation uses a two-pass compensated summation algorithm to minimize roundoff errors (see the references).

References

William H. Press et al., Numerical Recipes in C: The Art of Scientific Computing, Second Edition (1997 reprint) Cambridge University Press, page 613.

Definition at line 2488 of file Math.h.

## ◆ Variance() [2/2]

template<typename T >
 double pcl::Variance ( const T * i, const T * j )
inline

Returns the variance from the mean of a sequence [i,j).

For sequences of less than two elements, this function returns zero.

This implementation uses a two-pass compensated summation algorithm to minimize roundoff errors (see References).

References

William H. Press et al., Numerical Recipes in C: The Art of Scientific Computing, Second Edition (1997 reprint) Cambridge University Press, page 613.

Definition at line 2520 of file Math.h.