STK++ 0.9.13
STK::Stat::Univariate< TContainer1D, Real > Class Template Reference

Computation of the univariate Statistics of a Real Variable. More...

#include <STK_Stat_UnivariateReal.h>

Public Member Functions

 Univariate (TContainer1D const &V, bool sorted=false)
 Default constructor Copy locally the variable V and set dimensions.
 
 Univariate (TContainer1D const &V, TContainer1D const &W, bool sorted=false)
 Default constructor for weighted variables.
 
 Univariate (const Univariate &stat)
 Copy constructor.
 
 ~Univariate ()
 destructor.
 
Univariateoperator= (const Univariate &stat)
 Operator = : overwrite the Univariate with stat.
 
template<class Vector >
void setData (Vector const &V, bool sorted=false)
 Compute the statistics of a new Variable.
 
template<class Vector , class Weights >
void setData (Vector const &V, Weights const &W, bool sorted=false)
 Compute the statistics of a new weighted Variable.
 
const int nbSamples () const
 get the number of samples
 
const int nbAvailableSamples () const
 get the number of available samples (not missing)
 
const int nbMissingSamples () const
 get the number of missing samples
 
const Real min () const
 get the min of the variable
 
const Real max () const
 get the max of the variable
 
const Real aMax () const
 get the absolute maximal value
 
const Real mean () const
 get the mean of the variable
 
const Real median () const
 get the median of the variable
 
const Real variance () const
 get the variance of the variable (division by n)
 
const Real unbiasedVariance () const
 get the unbiased Variance of the variable (division by n-1)
 
const Real std () const
 get the standard deviation of the variable
 
const Real unbiasedStd () const
 get the sample standard deviation of the variable
 
const Real mad () const
 get the median absolute deviation of the variable
 
const Real kurtosis () const
 get the kurtosis of the variable
 
const Real skewness () const
 get the skewness of the variable
 
Variable< Real > constquartiles () const
 get the quartiles of the variable (25%)
 
Variable< Real > constdeciles () const
 get the deciles of the varibales (10%)
 
Variable< Real > constviceciles () const
 get the viceciles of the variable (5%)
 
Variable< Real > constpercentiles () const
 get the percentiles of the variable (1%)
 
template<class OtherArray >
void compQuantiles (OtherArray &T)
 Compute the quantiles of the sorted variable V_ and store the result in the array T.
 

Protected Attributes

int nbSamples_
 Number of samples.
 
int nbAvailable_
 Number of Available samples.
 
int nbMiss_
 Number of missing samples.
 
TContainer1D V_
 local copy of the variable
 
TContainer1D W_
 local copy of the weights
 
bool weighted_
 Samples are weighted ?
 
bool sorted_
 Samples are sorted ?
 
bool comporder_
 Orders Statistics are computed ?
 
bool compstat_
 Usuals Statistics are computed ?
 
Real sumweights_
 Sum of the weights.
 
Real sum2weights_
 Sum of the square of the weights.
 
Real min_
 Min of the variable.
 
Real max_
 Max of the variable.
 
Real amax_
 Absolute maximal value.
 
Real mean_
 mean of the variable
 
Real median_
 median of the variable
 
Real var_
 Variance of the variable (division by n)
 
Real uvar_
 Unbiased Variance of the variable (division by n-1)
 
Real std_
 Standard deviation of the variable (n)
 
Real ustd_
 Sample standard deviation of the variable (n-1)
 
Real mad_
 absolute deviation of the variable
 
Real kurtosis_
 kurtosis of the variable
 
Real skewness_
 Skewness of the variable.
 
Variable< Realquartiles_
 Quartiles (25%)
 
Variable< Realdeciles_
 Deciles (10%)
 
Variable< Realviceciles_
 viceciles (5%)
 
Variable< Realpercentiles_
 percentiles (1%)
 

Private Member Functions

void initializeVariable ()
 Initialize the container in order to discard the missing elements in the non weighted case.
 
void initializeVariableAndWeights ()
 Initialize the containers in order to discard the missing elements in the weighted case.
 
void compStatistics ()
 Compute the usual statistics of the variable:
 
void compWeightedStatistics ()
 Compute the usual weighted statistics of the variable.
 
void compOrderStatistics ()
 Compute the Order Statistics of the variable.
 

Detailed Description

template<class TContainer1D>
class STK::Stat::Univariate< TContainer1D, Real >

Computation of the univariate Statistics of a Real Variable.

This is a specialization of the class Univariate for the type Real.

The template parameter TContainer1D is the type of container used for storing the data : It should derive from ITContainer and contain elements of type Real.

This specialization propose also statics methods for computing the (weighted) mean and the (weighted) variance.

Definition at line 63 of file STK_Stat_UnivariateReal.h.

Constructor & Destructor Documentation

◆ Univariate() [1/3]

template<class TContainer1D >
STK::Stat::Univariate< TContainer1D, Real >::Univariate ( TContainer1D const V,
bool  sorted = false 
)
inline

Default constructor Copy locally the variable V and set dimensions.

The statistics are then computed.

Parameters
Vvariable
sortedtrue if the variable is sorted, false otherwise

Definition at line 72 of file STK_Stat_UnivariateReal.h.

73 : nbSamples_(V.size())
74 , nbAvailable_(V.size())
75 , nbMiss_(0)
76 , V_(V)
77 , W_()
78 , weighted_(false)
79 , sorted_(sorted)
80 , comporder_(false)
81 , compstat_(false)
82 , sumweights_(0.)
83 , sum2weights_(0.)
93 , quartiles_(3, Arithmetic<Real>::NA(), String(_T("Quartiles")))
94 , deciles_(9, Arithmetic<Real>::NA(), String(_T("Deciles")))
95 , viceciles_(19, Arithmetic<Real>::NA(), String(_T("Viceciles")))
96 , percentiles_(99, Arithmetic<Real>::NA(), String(_T("Percentiles")))
97 {
102 }
#define STK_STATIC_ASSERT_ONE_DIMENSION_ONLY(EXPR)
#define _T(x)
Let x unmodified.
void compOrderStatistics()
Compute the Order Statistics of the variable.
Real var_
Variance of the variable (division by n)
Real uvar_
Unbiased Variance of the variable (division by n-1)
Real mad_
absolute deviation of the variable
void compStatistics()
Compute the usual statistics of the variable:
Real std_
Standard deviation of the variable (n)
Real ustd_
Sample standard deviation of the variable (n-1)
TContainer1D W_
local copy of the weights
bool comporder_
Orders Statistics are computed ?
Real sum2weights_
Sum of the square of the weights.
bool compstat_
Usuals Statistics are computed ?
void initializeVariable()
Initialize the container in order to discard the missing elements in the non weighted case.
TContainer1D V_
local copy of the variable
std::basic_string< Char > String
STK fundamental type of a String.
static Type NA()
Adding a Non Available (NA) special number.

References STK_STATIC_ASSERT_ONE_DIMENSION_ONLY.

◆ Univariate() [2/3]

template<class TContainer1D >
STK::Stat::Univariate< TContainer1D, Real >::Univariate ( TContainer1D const V,
TContainer1D const W,
bool  sorted = false 
)
inline

Default constructor for weighted variables.

Copy locally the variable V, the weights W and set dimensions. No statistics except min_, max_ and amax_ are calculated at this stage.

Parameters
V,Wthe variable and the weights
sortedtrue if the variable is sorted, false otherwise

Definition at line 111 of file STK_Stat_UnivariateReal.h.

112 : nbSamples_(V.size())
113 , nbAvailable_(V.size())
114 , nbMiss_(0)
115 , V_(V)
116 , W_(W)
117 , weighted_(true)
118 , sorted_(sorted)
119 , comporder_(false)
120 , compstat_(false)
121 , sumweights_(0.0)
122 , sum2weights_(0.0)
132 , quartiles_(3)
133 , deciles_(9)
134 , viceciles_(19)
135 , percentiles_(99)
136 {
138 // check weights size
139 if ((V_.range() != W_.range()))
140 { STKRUNTIME_ERROR_NO_ARG(Univariate::Univariate(V, W, sorted),V and W have different range);}
144 }
#define STKRUNTIME_ERROR_NO_ARG(Where, Error)
Definition STK_Macros.h:138
void initializeVariableAndWeights()
Initialize the containers in order to discard the missing elements in the weighted case.
void compWeightedStatistics()
Compute the usual weighted statistics of the variable.

References STK_STATIC_ASSERT_ONE_DIMENSION_ONLY, and STKRUNTIME_ERROR_NO_ARG.

◆ Univariate() [3/3]

template<class TContainer1D >
STK::Stat::Univariate< TContainer1D, Real >::Univariate ( const Univariate< TContainer1D, Real > &  stat)
inline

Copy constructor.

Parameters
statthe univariate statistics to copy

Definition at line 148 of file STK_Stat_UnivariateReal.h.

149 : nbSamples_(stat.nbSamples_)
150 , nbAvailable_(stat.nbAvailable_)
151 , nbMiss_(stat.nbMiss_)
152 , V_(stat.V_)
153 , W_(stat.W_)
154 , weighted_(stat.weighted_)
155 , sorted_(stat.sorted_)
156 , comporder_(stat.comporder_)
157 , compstat_(stat.compstat_)
158 , sumweights_(stat.sumweights_)
159 , sum2weights_(stat.sum2weights_)
160 , min_(stat.min_)
161 , max_(stat.max_)
162 , amax_(stat.amax_)
163 , mean_(stat.mean_)
164 , median_(stat.median_)
165 , var_(stat.var_)
166 , uvar_(stat.uvar_)
167 , std_(stat.std_)
168 , ustd_(stat.ustd_)
169 , mad_(stat.mad_)
170 , kurtosis_(stat.kurtosis_)
171 , skewness_(stat.skewness_)
172 , quartiles_(stat.quartiles_)
173 , deciles_(stat.deciles_)
174 , viceciles_(stat.viceciles_)
175 , percentiles_(stat.percentiles_)
176 {}

◆ ~Univariate()

template<class TContainer1D >
STK::Stat::Univariate< TContainer1D, Real >::~Univariate ( )
inline

destructor.

Definition at line 179 of file STK_Stat_UnivariateReal.h.

179{}

Member Function Documentation

◆ aMax()

template<class TContainer1D >
const Real STK::Stat::Univariate< TContainer1D, Real >::aMax ( ) const
inline

get the absolute maximal value

Definition at line 313 of file STK_Stat_UnivariateReal.h.

313{return amax_;}

◆ compOrderStatistics()

template<class TContainer1D >
void STK::Stat::Univariate< TContainer1D, Real >::compOrderStatistics ( )
inlineprivate

Compute the Order Statistics of the variable.

Definition at line 624 of file STK_Stat_UnivariateReal.h.

625 {
626 // no samples
627 if (nbAvailable_ == 0)
628 {
634 return;
635 }
636
637 // One observation
638 if (nbAvailable_ == 1)
639 {
640 median_ = max_;
642 deciles_ = max_;
645 return;
646 }
647 // sort values
648 if (!sorted_)
649 {
650 // if the Variable is not weighted, we can sort it directly
651 if (!weighted_) heapSort(V_);
652 else // otherwise we have to sort V_and W_ using indirection
653 {
654 TContainer1D const& Vconst = V_;
655 Array2DVector<int> I; // auxiliary Array for indirection
656 heapSort(I, Vconst);
657 applySort1D(V_, I);
658 applySort1D(W_, I);
659 }
660 sorted_ = true;
661 }
662 // Find the Quantiles of the distribution
667 // get the median
668 median_ = quartiles_[2];
669 }
void compQuantiles(OtherArray &T)
Compute the quantiles of the sorted variable V_ and store the result in the array T.
void heapSort(Vector &T)
Sort the container T in ascending order.
void applySort1D(Vector &T, VectorInt const &I)
Apply a sorting index array to the 1D container T.

References STK::applySort1D(), STK::heapSort(), and STK::Arithmetic< Type >::NA().

◆ compQuantiles()

template<class TContainer1D >
template<class OtherArray >
void STK::Stat::Univariate< TContainer1D, Real >::compQuantiles ( OtherArray T)
inline

Compute the quantiles of the sorted variable V_ and store the result in the array T.

The number of quantiles is given by the size of T. For exemple, if T.size() == 9, compQuantiles will return the deciles.

Parameters
TTContainer1Ds of the *tiles

Definition at line 352 of file STK_Stat_UnivariateReal.h.

353 {
354 if (!sorted_)
355 { STKRUNTIME_ERROR_NO_ARG(Univariate<TContainer1D>::compQuantiles(T),V_ is not sorted);}
356 // number of quantiles
357 int nt = T.size(), shift = V_.begin()-1;
358 Real n1 = Real(nbAvailable_+1), nt1 = Real(nt+1);
359
360 for (int j=T.begin(), k=1; j<T.end(); j++, k++)
361 {
362 // find index of the k-th quantile
363 Real find = Real(k*n1)/nt1; // compute the index in Real
364 int tind = std::max(1, int(find)); // in int
365 int tind1 = std::min(nbAvailable_, tind+1); // next
366 Real aux = find - Real(tind); // lower ponderation
367
368 // nbAvailable_+1 not perfectly divisible ? weighting...
369 aux ? T[j] = aux * V_[shift+tind] + (1.0-aux)*V_[shift+tind1]
370 : T[j] = V_[shift+tind];
371 }
372 }
double Real
STK fundamental type of Real values.

References STKRUNTIME_ERROR_NO_ARG.

◆ compStatistics()

template<class TContainer1D >
void STK::Stat::Univariate< TContainer1D, Real >::compStatistics ( )
inlineprivate

Compute the usual statistics of the variable:

  • mean the empirical mean of the variable
  • var_ the variance of of the variable (division by n)
  • uvar_ the sample variance of the variable (division by n-1)
  • std_ the standard deviation of the variable (n)
  • ustd_ the sample standard deviation of the variable (n-1)
  • mad_ the absolute deviation from the mean of the variable

Definition at line 460 of file STK_Stat_UnivariateReal.h.

461 {
462 // If there is no samples
463 if (nbAvailable_ == 0)
464 {
473 return;
474 }
475
476 // One observation
477 if (nbAvailable_ == 1)
478 {
479 mean_ = V_.front();
481 std_ = 0.0;
483 mad_ = 0.0;
484 kurtosis_ = 0.0;
485 skewness_ = 0.0;
486 return;
487 }
488 // get indexes
489 // get nbAvailable observation in Real
490 const Real n = (Real)nbAvailable_;
491 // first pass : compute the mean
492 // scale the samples for preventing overflows
493 mean_ = 0.;
494 {
495 if (amax_) // if the absolute maximal value is greater than 0
496 {
497 // sum samples with scaling
498 for (int i=V_.begin(); i<=V_.lastIdx(); i++)
499 mean_ += V_[i]/amax_;
500 // divide by the number of available observation
501 mean_ /= n;
502 // unscale
503 mean_ *= amax_;
504 }
505 }
506 // second pass : compute the variance, skewness and kurtosis
507 // initialize values
508 Real sum = 0.0, dev1, dev2;
509 var_ = 0.0;
510 mad_ = 0.0;
511 kurtosis_ = 0.0;
512 skewness_ = 0.0;
513 for (int i=V_.begin(); i<V_.end(); i++)
514 {
515 sum += (dev1 = V_[i]-mean_); // deviation from the mean
516 var_ += (dev2 = dev1*dev1); // squared deviation
517 mad_ += std::abs( dev1 ); // absolute deviation
518 skewness_ += dev2 * dev1; // cubic deviation
519 kurtosis_ += dev2 * dev2; // squared squared deviation
520 }
522 uvar_ = (var_ - sum*sum/n)/(n - 1.);
523 var_ = (var_ - sum*sum/n)/n;
524 std_ = sqrt((double)var_);
525 ustd_ = sqrt((double)uvar_);
526 // if there is variance
527 if (var_)
528 {
529 skewness_ /= n;
530 kurtosis_ /= n;
531
532 skewness_ /= (var_ * std_);
533 kurtosis_ /= (var_ * var_);
534 kurtosis_ -= 3.0;
535 }
536 else
537 {
538 skewness_ = 0.0;
539 kurtosis_ = 0.0;
540 }
541 // Statistics are computed
542 compstat_ = true;
543 }
hidden::FunctorTraits< Derived, SumOp >::Row sum(Derived const &A)
Compute the sum of A.

References STK::Arithmetic< Type >::NA(), and STK::Stat::sum().

◆ compWeightedStatistics()

template<class TContainer1D >
void STK::Stat::Univariate< TContainer1D, Real >::compWeightedStatistics ( )
inlineprivate

Compute the usual weighted statistics of the variable.

Definition at line 546 of file STK_Stat_UnivariateReal.h.

547 {
548 // If there is no samples
549 if (nbAvailable_ == 0)
550 {
559 return;
560 }
561
562 // One observation or pathological weights
564 {
565 mean_ = V_.front();
566 var_ = 0.;
568 std_ = 0.;
570 mad_ = 0.;
571 kurtosis_ = 0.;
572 skewness_ = 0.;
573 return;
574 }
575 // first pass : get the mean
576 // scale the samples for preventing overflows
577 mean_ = 0.;
578 if (amax_) // if the maximal value is greater than 0
579 {
580 // sum samples
581 for (int i=V_.begin(); i<V_.end(); i++)
582 mean_ += (W_[i]*V_[i])/amax_; // compute the mean with scaling
583 mean_ /= sumweights_; // weight the sum
584 mean_ *= amax_; // and unscale
585 }
586 // second pass : compute the variance, skewness and kurtosis
587 // initialize some values
588 Real sum = 0.0, dev1, dev2;
589 var_ = 0.0;
590 mad_ = 0.0;
591 kurtosis_ = 0.0;
592 skewness_ = 0.0;
593 for (int i=V_.begin(); i<V_.end(); i++)
594 {
595 Real weight = W_[i];
596 sum += weight * (dev1 = V_[i]-mean_); // deviation from the mean
597 var_ += weight * (dev2 = dev1*dev1); // squared value
598 mad_ += weight * std::abs(dev1); // absolute deviation from mean
599 skewness_ += weight * dev2 * dev1;
600 kurtosis_ += weight * dev2 * dev2;
601 }
602 mad_ /= sumweights_;
605 std_ = sqrt((double)var_);
606 ustd_ = sqrt((double)uvar_);
607 // if there is variance
608 if (var_)
609 {
612 kurtosis_ -= 3.0;
613 }
614 else
615 {
616 skewness_ = 0.0;
617 kurtosis_ = 0.0;
618 }
619 // Stat are computed
620 compstat_ = true;
621 }

References STK::Arithmetic< Type >::NA(), and STK::Stat::sum().

◆ deciles()

template<class TContainer1D >
Variable< Real > const & STK::Stat::Univariate< TContainer1D, Real >::deciles ( ) const
inline

get the deciles of the varibales (10%)

Definition at line 339 of file STK_Stat_UnivariateReal.h.

339{return deciles_;}

◆ initializeVariable()

template<class TContainer1D >
void STK::Stat::Univariate< TContainer1D, Real >::initializeVariable ( )
inlineprivate

Initialize the container in order to discard the missing elements in the non weighted case.

Definition at line 378 of file STK_Stat_UnivariateReal.h.

379 {
380 // initialize the extreme values
381 min_ = Arithmetic<Real>::max();
382 max_ = -Arithmetic<Real>::max();
383 // discard missing values
384 for (int i=V_.lastIdx(); i>=V_.begin(); i--)
385 {
386 if ( isNA(V_[i]) )
387 {
388 // if NA
389 nbAvailable_--; // decrease nbAvailable_
390 nbMiss_++; // increase nbMiss_
391 V_.erase(i); // Delete the current row
392 }
393 else
394 {
395 min_ = std::min((Real)V_[i], min_); // update min_
396 max_ = std::max((Real)V_[i], max_); // update max_
397 }
398 }
399 // all weights are 1/n.
400 sumweights_ = 1.0;
402
403 // no samples
404 if (nbAvailable_ == 0)
405 {
409 }
410 else // one or more samples : compute amax
411 amax_ = std::max(std::abs(min_), std::abs(max_));
412 }
bool isNA(Type const &x)
utility method allowing to know if a value is a NA (Not Available) value

References STK::isNA(), and STK::Arithmetic< Type >::NA().

◆ initializeVariableAndWeights()

template<class TContainer1D >
void STK::Stat::Univariate< TContainer1D, Real >::initializeVariableAndWeights ( )
inlineprivate

Initialize the containers in order to discard the missing elements in the weighted case.

Definition at line 417 of file STK_Stat_UnivariateReal.h.

418 {
419 // initialize the extreme values
420 min_ = Arithmetic<Real>::max();
421 max_ = -Arithmetic<Real>::max();
422
423 // discard missing values or values without weights
424 for (int i=V_.lastIdx(); i>=V_.begin(); i--)
425 {
426 if ( isNA(V_[i])||isNA(W_[i]))
427 {
428 V_.erase(i); // Delete the current row
429 W_.erase(i); // for the weights too
430 nbAvailable_--; // decrease number of samples
431 nbMiss_++; // increase number of missing values
432 }
433 else
434 {
435 min_ = std::min(V_[i], min_); // update min_
436 max_ = std::max(V_[i], max_); // update max_
437 sumweights_ += (W_[i] = std::abs((Real)W_[i]));// sum absolute weights
438 sum2weights_ += W_[i] * W_[i]; // sum squared weights
439 }
440 }
441 // no samples
442 if (nbAvailable_ == 0)
443 {
447 }
448 else // one or more samples : compute amax
449 amax_ = std::max(std::abs(min_), std::abs(max_));
450 }

References STK::isNA(), and STK::Arithmetic< Type >::NA().

◆ kurtosis()

template<class TContainer1D >
const Real STK::Stat::Univariate< TContainer1D, Real >::kurtosis ( ) const
inline

get the kurtosis of the variable

Definition at line 332 of file STK_Stat_UnivariateReal.h.

332{return kurtosis_;}

◆ mad()

template<class TContainer1D >
const Real STK::Stat::Univariate< TContainer1D, Real >::mad ( ) const
inline

get the median absolute deviation of the variable

Definition at line 329 of file STK_Stat_UnivariateReal.h.

329{ return( mad_);}

◆ max()

template<class TContainer1D >
const Real STK::Stat::Univariate< TContainer1D, Real >::max ( ) const
inline

get the max of the variable

Definition at line 311 of file STK_Stat_UnivariateReal.h.

311{return max_;}

◆ mean()

template<class TContainer1D >
const Real STK::Stat::Univariate< TContainer1D, Real >::mean ( ) const
inline

get the mean of the variable

Definition at line 316 of file STK_Stat_UnivariateReal.h.

316{return mean_;}

◆ median()

template<class TContainer1D >
const Real STK::Stat::Univariate< TContainer1D, Real >::median ( ) const
inline

get the median of the variable

Definition at line 318 of file STK_Stat_UnivariateReal.h.

318{return median_;}

◆ min()

template<class TContainer1D >
const Real STK::Stat::Univariate< TContainer1D, Real >::min ( ) const
inline

get the min of the variable

Definition at line 309 of file STK_Stat_UnivariateReal.h.

309{return min_;}

◆ nbAvailableSamples()

template<class TContainer1D >
const int STK::Stat::Univariate< TContainer1D, Real >::nbAvailableSamples ( ) const
inline

get the number of available samples (not missing)

Definition at line 304 of file STK_Stat_UnivariateReal.h.

304{return nbAvailable_;}

◆ nbMissingSamples()

template<class TContainer1D >
const int STK::Stat::Univariate< TContainer1D, Real >::nbMissingSamples ( ) const
inline

get the number of missing samples

Definition at line 306 of file STK_Stat_UnivariateReal.h.

306{return nbMiss_;}

◆ nbSamples()

template<class TContainer1D >
const int STK::Stat::Univariate< TContainer1D, Real >::nbSamples ( ) const
inline

get the number of samples

Definition at line 302 of file STK_Stat_UnivariateReal.h.

302{return nbSamples_;}

◆ operator=()

template<class TContainer1D >
Univariate & STK::Stat::Univariate< TContainer1D, Real >::operator= ( const Univariate< TContainer1D, Real > &  stat)
inline

Operator = : overwrite the Univariate with stat.

Definition at line 182 of file STK_Stat_UnivariateReal.h.

183 {
184 nbSamples_ = stat.nbSamples_;
185 nbAvailable_ = stat.nbAvailable_;
186 nbMiss_ = stat.nbMiss_;
187 V_ = stat.V_;
188 W_ = stat.W_;
189 weighted_ = stat.weighted_;
190 sorted_ = stat.sorted_;
191 comporder_ = stat.comporder_;
192 compstat_ = stat.compstat_;
193 sumweights_ = stat.sumweights_;
194 sum2weights_ = stat.sum2weights_;
195 min_ = stat.min_;
196 max_ = stat.max_;
197 amax_ = stat.amax_;
198 mean_ = stat.mean_;
199 median_ = stat.median_;
200 var_ = stat.var_;
201 uvar_ = stat.uvar_;
202 std_ = stat.std_;
203 ustd_ = stat.ustd_;
204 mad_ = stat.mad_;
205 kurtosis_ = stat.kurtosis_;
206 skewness_ = stat.skewness_;
207 quartiles_ = stat.quartiles_;
208 deciles_ = stat.deciles_;
209 viceciles_ = stat.viceciles_;
210 percentiles_ = stat.percentiles_;
211
212 return *this;
213 }

◆ percentiles()

template<class TContainer1D >
Variable< Real > const & STK::Stat::Univariate< TContainer1D, Real >::percentiles ( ) const
inline

get the percentiles of the variable (1%)

Definition at line 343 of file STK_Stat_UnivariateReal.h.

343{ return percentiles_;}

◆ quartiles()

template<class TContainer1D >
Variable< Real > const & STK::Stat::Univariate< TContainer1D, Real >::quartiles ( ) const
inline

get the quartiles of the variable (25%)

Definition at line 337 of file STK_Stat_UnivariateReal.h.

337{return quartiles_;}

◆ setData() [1/2]

template<class TContainer1D >
template<class Vector >
void STK::Stat::Univariate< TContainer1D, Real >::setData ( Vector const V,
bool  sorted = false 
)
inline

Compute the statistics of a new Variable.

Parameters
Vthe variable to set
sortedtrue if the variable is sorted

Definition at line 220 of file STK_Stat_UnivariateReal.h.

221 {
223 // set variable and weights
224 V_ = V;
225 W_.clear(); // no weights
226 // initialize dimensions
227 nbSamples_ = V_.size();
228 nbAvailable_ = V_.size();
229 nbMiss_ = 0;
230 // initialize data
231 weighted_ = false;
232 sorted_ = sorted;
233 comporder_ = false;
234 compstat_ = false;
235 sumweights_ = 0.0;
236 sum2weights_ = 0.0;
250
254 }
Array2DVector< Real > Vector
final class for a Real vertical container.

References STK::IArray2D< Derived >::clear(), STK::Arithmetic< Type >::NA(), and STK_STATIC_ASSERT_ONE_DIMENSION_ONLY.

◆ setData() [2/2]

template<class TContainer1D >
template<class Vector , class Weights >
void STK::Stat::Univariate< TContainer1D, Real >::setData ( Vector const V,
Weights const W,
bool  sorted = false 
)
inline

Compute the statistics of a new weighted Variable.

Parameters
V,Wthe variable and the weights to set
sortedtrue if the variable is sorted

Definition at line 261 of file STK_Stat_UnivariateReal.h.

262 {
265 // check range size
266 if ((V.range() != W.range()))
267 { STKRUNTIME_ERROR_NO_ARG(Univariate::setData(V, W, sorted),V and W have different range);}
268 // set variable and weights
269 V_ = V;
270 W_ = W;
271 // initialize dimensions
272 nbSamples_ = V_.size();
273 nbAvailable_ = V_.size();
274 nbMiss_ = 0;
275 // initialize data
276 weighted_ = true;
277 sorted_ = sorted;
278 comporder_ = false;
279 compstat_ = false;
280 sumweights_ = 0.0;
281 sum2weights_ = 0.0;
295
299 }

References STK::Arithmetic< Type >::NA(), STK_STATIC_ASSERT_ONE_DIMENSION_ONLY, and STKRUNTIME_ERROR_NO_ARG.

◆ skewness()

template<class TContainer1D >
const Real STK::Stat::Univariate< TContainer1D, Real >::skewness ( ) const
inline

get the skewness of the variable

Definition at line 334 of file STK_Stat_UnivariateReal.h.

334{return skewness_;}

◆ std()

template<class TContainer1D >
const Real STK::Stat::Univariate< TContainer1D, Real >::std ( ) const
inline

get the standard deviation of the variable

Definition at line 325 of file STK_Stat_UnivariateReal.h.

325{return std_;}

◆ unbiasedStd()

template<class TContainer1D >
const Real STK::Stat::Univariate< TContainer1D, Real >::unbiasedStd ( ) const
inline

get the sample standard deviation of the variable

Definition at line 327 of file STK_Stat_UnivariateReal.h.

327{return ustd_;}

◆ unbiasedVariance()

template<class TContainer1D >
const Real STK::Stat::Univariate< TContainer1D, Real >::unbiasedVariance ( ) const
inline

get the unbiased Variance of the variable (division by n-1)

Definition at line 323 of file STK_Stat_UnivariateReal.h.

323{return uvar_;}

◆ variance()

template<class TContainer1D >
const Real STK::Stat::Univariate< TContainer1D, Real >::variance ( ) const
inline

get the variance of the variable (division by n)

Definition at line 321 of file STK_Stat_UnivariateReal.h.

321{return var_;}

◆ viceciles()

template<class TContainer1D >
Variable< Real > const & STK::Stat::Univariate< TContainer1D, Real >::viceciles ( ) const
inline

get the viceciles of the variable (5%)

Definition at line 341 of file STK_Stat_UnivariateReal.h.

341{ return viceciles_;}

Member Data Documentation

◆ amax_

template<class TContainer1D >
Real STK::Stat::Univariate< TContainer1D, Real >::amax_
protected

Absolute maximal value.

Definition at line 692 of file STK_Stat_UnivariateReal.h.

◆ comporder_

template<class TContainer1D >
bool STK::Stat::Univariate< TContainer1D, Real >::comporder_
protected

Orders Statistics are computed ?

Definition at line 684 of file STK_Stat_UnivariateReal.h.

◆ compstat_

template<class TContainer1D >
bool STK::Stat::Univariate< TContainer1D, Real >::compstat_
protected

Usuals Statistics are computed ?

Definition at line 685 of file STK_Stat_UnivariateReal.h.

◆ deciles_

template<class TContainer1D >
Variable<Real> STK::Stat::Univariate< TContainer1D, Real >::deciles_
protected

Deciles (10%)

Definition at line 705 of file STK_Stat_UnivariateReal.h.

◆ kurtosis_

template<class TContainer1D >
Real STK::Stat::Univariate< TContainer1D, Real >::kurtosis_
protected

kurtosis of the variable

Definition at line 701 of file STK_Stat_UnivariateReal.h.

◆ mad_

template<class TContainer1D >
Real STK::Stat::Univariate< TContainer1D, Real >::mad_
protected

absolute deviation of the variable

Definition at line 700 of file STK_Stat_UnivariateReal.h.

◆ max_

template<class TContainer1D >
Real STK::Stat::Univariate< TContainer1D, Real >::max_
protected

Max of the variable.

Definition at line 691 of file STK_Stat_UnivariateReal.h.

◆ mean_

template<class TContainer1D >
Real STK::Stat::Univariate< TContainer1D, Real >::mean_
protected

mean of the variable

Definition at line 694 of file STK_Stat_UnivariateReal.h.

◆ median_

template<class TContainer1D >
Real STK::Stat::Univariate< TContainer1D, Real >::median_
protected

median of the variable

Definition at line 695 of file STK_Stat_UnivariateReal.h.

◆ min_

template<class TContainer1D >
Real STK::Stat::Univariate< TContainer1D, Real >::min_
protected

Min of the variable.

Definition at line 690 of file STK_Stat_UnivariateReal.h.

◆ nbAvailable_

template<class TContainer1D >
int STK::Stat::Univariate< TContainer1D, Real >::nbAvailable_
protected

Number of Available samples.

Definition at line 674 of file STK_Stat_UnivariateReal.h.

◆ nbMiss_

template<class TContainer1D >
int STK::Stat::Univariate< TContainer1D, Real >::nbMiss_
protected

Number of missing samples.

Definition at line 675 of file STK_Stat_UnivariateReal.h.

◆ nbSamples_

template<class TContainer1D >
int STK::Stat::Univariate< TContainer1D, Real >::nbSamples_
protected

Number of samples.

Definition at line 673 of file STK_Stat_UnivariateReal.h.

◆ percentiles_

template<class TContainer1D >
Variable<Real> STK::Stat::Univariate< TContainer1D, Real >::percentiles_
protected

percentiles (1%)

Definition at line 707 of file STK_Stat_UnivariateReal.h.

◆ quartiles_

template<class TContainer1D >
Variable<Real> STK::Stat::Univariate< TContainer1D, Real >::quartiles_
protected

Quartiles (25%)

Definition at line 704 of file STK_Stat_UnivariateReal.h.

◆ skewness_

template<class TContainer1D >
Real STK::Stat::Univariate< TContainer1D, Real >::skewness_
protected

Skewness of the variable.

Definition at line 702 of file STK_Stat_UnivariateReal.h.

◆ sorted_

template<class TContainer1D >
bool STK::Stat::Univariate< TContainer1D, Real >::sorted_
protected

Samples are sorted ?

Definition at line 683 of file STK_Stat_UnivariateReal.h.

◆ std_

template<class TContainer1D >
Real STK::Stat::Univariate< TContainer1D, Real >::std_
protected

Standard deviation of the variable (n)

Definition at line 698 of file STK_Stat_UnivariateReal.h.

◆ sum2weights_

template<class TContainer1D >
Real STK::Stat::Univariate< TContainer1D, Real >::sum2weights_
protected

Sum of the square of the weights.

Definition at line 689 of file STK_Stat_UnivariateReal.h.

◆ sumweights_

template<class TContainer1D >
Real STK::Stat::Univariate< TContainer1D, Real >::sumweights_
protected

Sum of the weights.

Definition at line 688 of file STK_Stat_UnivariateReal.h.

◆ ustd_

template<class TContainer1D >
Real STK::Stat::Univariate< TContainer1D, Real >::ustd_
protected

Sample standard deviation of the variable (n-1)

Definition at line 699 of file STK_Stat_UnivariateReal.h.

◆ uvar_

template<class TContainer1D >
Real STK::Stat::Univariate< TContainer1D, Real >::uvar_
protected

Unbiased Variance of the variable (division by n-1)

Definition at line 697 of file STK_Stat_UnivariateReal.h.

◆ V_

template<class TContainer1D >
TContainer1D STK::Stat::Univariate< TContainer1D, Real >::V_
protected

local copy of the variable

Definition at line 678 of file STK_Stat_UnivariateReal.h.

◆ var_

template<class TContainer1D >
Real STK::Stat::Univariate< TContainer1D, Real >::var_
protected

Variance of the variable (division by n)

Definition at line 696 of file STK_Stat_UnivariateReal.h.

◆ viceciles_

template<class TContainer1D >
Variable<Real> STK::Stat::Univariate< TContainer1D, Real >::viceciles_
protected

viceciles (5%)

Definition at line 706 of file STK_Stat_UnivariateReal.h.

◆ W_

template<class TContainer1D >
TContainer1D STK::Stat::Univariate< TContainer1D, Real >::W_
protected

local copy of the weights

Definition at line 679 of file STK_Stat_UnivariateReal.h.

◆ weighted_

template<class TContainer1D >
bool STK::Stat::Univariate< TContainer1D, Real >::weighted_
protected

Samples are weighted ?

Definition at line 682 of file STK_Stat_UnivariateReal.h.


The documentation for this class was generated from the following file: