STK++ 0.9.13
STK::Stat::Multivariate< Array, WColVector, Type > Class Template Reference

Computation of the multivariate statistics of a Variable. More...

#include <STK_Stat_Multivariate.h>

Inheritance diagram for STK::Stat::Multivariate< Array, WColVector, Type >:
Inheritance graph

Public Types

typedef IRunnerUnsupervised< Array, WColVector > Runner2D
 

Public Member Functions

 Multivariate (Array const *p_data)
 Constructor.
 
 Multivariate (Array const &data)
 Constructor.
 
virtual ~Multivariate ()
 virtual destructor.
 
int nbSamples () const
 
int nbVariable () const
 
Array1D< int > constnbMissingSamples () const
 Number of missing values.
 
Array1D< int > constnbAvailableSamples () const
 
virtual bool run ()
 run the estimation of the Multivariate statistics.
 
virtual bool run (WColVector const &weights)
 run the estimation of the weighted multivariate statistics.
 
- Public Member Functions inherited from STK::IRunnerUnsupervised< Array, WColVector >
Array constp_data () const
 get the data set
 
virtual void setData (Array const *p_data)
 Set the data set.
 
virtual void setData (Array const &data)
 Set the data set.
 
- Public Member Functions inherited from STK::IRunnerBase
String consterror () const
 get the last error message.
 

Protected Attributes

int nbSamples_
 number of samples
 
int nbVar_
 Number of variables.
 
Array1D< intnbMiss_
 number of missing data of each variables
 
Array1D< intnbAvailable_
 number of observed data of each variables
 
- Protected Attributes inherited from STK::IRunnerUnsupervised< Array, WColVector >
Array constp_data_
 A pointer on the original data set.
 
- Protected Attributes inherited from STK::IRunnerBase
String msg_error_
 String with the last error message.
 
bool hasRun_
 true if run has been used, false otherwise
 

Additional Inherited Members

- Protected Member Functions inherited from STK::IRunnerUnsupervised< Array, WColVector >
 IRunnerUnsupervised ()
 default constructor.
 
 IRunnerUnsupervised (Array const *const p_data)
 constructor with a pointer on the constant data set
 
 IRunnerUnsupervised (Array const &data)
 constructor with a constant reference on the data set
 
 IRunnerUnsupervised (IRunnerUnsupervised const &runner)
 copy constructor
 
 ~IRunnerUnsupervised ()
 destructor
 
- Protected Member Functions inherited from STK::IRunnerBase
 IRunnerBase ()
 default constructor
 
 IRunnerBase (IRunnerBase const &runner)
 copy constructor
 
virtual ~IRunnerBase ()
 destructor
 
virtual void update ()
 update the runner.
 

Detailed Description

template<class Array, class WColVector, typename Type = typename Array::Type>
class STK::Stat::Multivariate< Array, WColVector, Type >

Computation of the multivariate statistics of a Variable.

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

Definition at line 54 of file STK_Stat_Multivariate.h.

Member Typedef Documentation

◆ Runner2D

template<class Array , class WColVector , typename Type = typename Array::Type>
typedef IRunnerUnsupervised< Array, WColVector> STK::Stat::Multivariate< Array, WColVector, Type >::Runner2D

Definition at line 57 of file STK_Stat_Multivariate.h.

Constructor & Destructor Documentation

◆ Multivariate() [1/2]

template<class Array , class WColVector , typename Type = typename Array::Type>
STK::Stat::Multivariate< Array, WColVector, Type >::Multivariate ( Array const p_data)
inline

Constructor.

Data set are initialized but no computation is done in this constructor. Statistics of the number of missing data and available data are delegated to derived classes.

Parameters
p_datathe data set

Definition at line 64 of file STK_Stat_Multivariate.h.

66 , nbSamples_(0)
67 , nbVar_(0)
68 , nbMiss_()
69 {}
Array const * p_data() const
get the data set
IRunnerUnsupervised< Array, WColVector > Runner2D
int nbSamples_
number of samples
Array1D< int > nbMiss_
number of missing data of each variables
int nbVar_
Number of variables.

◆ Multivariate() [2/2]

template<class Array , class WColVector , typename Type = typename Array::Type>
STK::Stat::Multivariate< Array, WColVector, Type >::Multivariate ( Array const data)
inline

Constructor.

Data set are initialized but no computation is done in this constructor. Statistics of the number of missing data and available data are delegated to derived classes.

Parameters
datathe data set

Definition at line 77 of file STK_Stat_Multivariate.h.

78 : Runner2D(data)
79 , nbSamples_()
80 , nbVar_()
81 , nbMiss_()
82 {}

◆ ~Multivariate()

template<class Array , class WColVector , typename Type = typename Array::Type>
virtual STK::Stat::Multivariate< Array, WColVector, Type >::~Multivariate ( )
inlinevirtual

virtual destructor.

Definition at line 84 of file STK_Stat_Multivariate.h.

84{}

Member Function Documentation

◆ nbAvailableSamples()

template<class Array , class WColVector , typename Type = typename Array::Type>
Array1D< int > const & STK::Stat::Multivariate< Array, WColVector, Type >::nbAvailableSamples ( ) const
inline
Returns
An array with the number of observed values for each variables of the data set (not missing).

Definition at line 97 of file STK_Stat_Multivariate.h.

97{return nbAvailable_;}
Array1D< int > nbAvailable_
number of observed data of each variables

References STK::Stat::Multivariate< Array, WColVector, Type >::nbAvailable_.

◆ nbMissingSamples()

template<class Array , class WColVector , typename Type = typename Array::Type>
Array1D< int > const & STK::Stat::Multivariate< Array, WColVector, Type >::nbMissingSamples ( ) const
inline

Number of missing values.

Returns
An array with the number of missing values for each variables of the data set

Definition at line 93 of file STK_Stat_Multivariate.h.

93{return nbMiss_;}

References STK::Stat::Multivariate< Array, WColVector, Type >::nbMiss_.

◆ nbSamples()

template<class Array , class WColVector , typename Type = typename Array::Type>
int STK::Stat::Multivariate< Array, WColVector, Type >::nbSamples ( ) const
inline
Returns
the number of samples in the data set (the number of rows)

Definition at line 86 of file STK_Stat_Multivariate.h.

86{return nbSamples_;}

References STK::Stat::Multivariate< Array, WColVector, Type >::nbSamples_.

◆ nbVariable()

template<class Array , class WColVector , typename Type = typename Array::Type>
int STK::Stat::Multivariate< Array, WColVector, Type >::nbVariable ( ) const
inline
Returns
the number of variables in the data set (the number of columns)

Definition at line 88 of file STK_Stat_Multivariate.h.

88{return nbVar_;}

References STK::Stat::Multivariate< Array, WColVector, Type >::nbVar_.

◆ run() [1/2]

template<class Array , class WColVector , typename Type = typename Array::Type>
virtual bool STK::Stat::Multivariate< Array, WColVector, Type >::run ( )
inlinevirtual

run the estimation of the Multivariate statistics.

Implements STK::IRunnerUnsupervised< Array, WColVector >.

Definition at line 100 of file STK_Stat_Multivariate.h.

101 {
102 if (!this->p_data_)
103 { this->msg_error_ = STKERROR_NO_ARG(Multivariate<Array>::run(),data are not set);
104 return false;
105 }
106 nbSamples_ = this->p_data_->sizeRows();
107 nbVar_ = this->p_data_->sizeCols();
108 nbMiss_.resize(this->p_data_->cols());
109 nbAvailable_.resize(this->p_data_->cols());
110 // for each variables
111 for (int j= this->p_data_->beginCols(); j<= this->p_data_->lastIdxCols(); j++)
112 {
113 // number of observations
114 int nobs = nbSamples_;
115 // compute the mean
116 for (int i= this->p_data_->beginRows(); i<= this->p_data_->lastIdxRows(); i++)
117 { if (!Arithmetic<Type>::isFinite((*this->p_data_)(i,j))) nobs--;}
118 nbAvailable_[j] = nobs;
119 nbMiss_[j] = nbSamples_ - nobs;
120 }
121 return true;
122 }
#define STKERROR_NO_ARG(Where, Error)
Definition STK_Macros.h:49
String msg_error_
String with the last error message.
Definition STK_IRunner.h:96
Array const * p_data_
A pointer on the original data set.
Derived & resize(Range const &I=RowRange())
virtual bool run()
run the estimation of the Multivariate statistics.
static bool isFinite(Type const &x)

References STK::IRunnerBase::msg_error_, STK::Stat::Multivariate< Array, WColVector, Type >::nbAvailable_, STK::Stat::Multivariate< Array, WColVector, Type >::nbMiss_, STK::Stat::Multivariate< Array, WColVector, Type >::nbSamples_, STK::Stat::Multivariate< Array, WColVector, Type >::nbVar_, STK::IRunnerUnsupervised< Array, WColVector >::p_data_, STK::ITContainer1D< Derived >::resize(), and STKERROR_NO_ARG.

Referenced by STK::Stat::Multivariate< Array, WColVector, Type >::run().

◆ run() [2/2]

template<class Array , class WColVector , typename Type = typename Array::Type>
virtual bool STK::Stat::Multivariate< Array, WColVector, Type >::run ( WColVector const weights)
inlinevirtual

run the estimation of the weighted multivariate statistics.

Parameters
weightsthe weights of the samples

Implements STK::IRunnerUnsupervised< Array, WColVector >.

Definition at line 126 of file STK_Stat_Multivariate.h.

127 {
128 if (!this->p_data_)
129 { this->msg_error_ = STKERROR_NO_ARG(Multivariate<Array>::run(),data are not set);
130 return false;
131 }
132 return run();
133 }

References STK::IRunnerBase::msg_error_, STK::IRunnerUnsupervised< Array, WColVector >::p_data_, STK::Stat::Multivariate< Array, WColVector, Type >::run(), and STKERROR_NO_ARG.

Member Data Documentation

◆ nbAvailable_

template<class Array , class WColVector , typename Type = typename Array::Type>
Array1D<int> STK::Stat::Multivariate< Array, WColVector, Type >::nbAvailable_
protected

◆ nbMiss_

template<class Array , class WColVector , typename Type = typename Array::Type>
Array1D<int> STK::Stat::Multivariate< Array, WColVector, Type >::nbMiss_
protected

◆ nbSamples_

template<class Array , class WColVector , typename Type = typename Array::Type>
int STK::Stat::Multivariate< Array, WColVector, Type >::nbSamples_
protected

◆ nbVar_

template<class Array , class WColVector , typename Type = typename Array::Type>
int STK::Stat::Multivariate< Array, WColVector, Type >::nbVar_
protected

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