STK++ 0.9.13
STK_Stat_Multivariate.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright (C) 2004-2016 Serge Iovleff, Université Lille 1, Inria
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this program; if not, write to the
16 Free Software Foundation, Inc.,
17 59 Temple Place,
18 Suite 330,
19 Boston, MA 02111-1307
20 USA
21
22 Contact : S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
23*/
24
25/*
26 * Project: stkpp::StatistiK::StatDesc
27 * Purpose: Compute multivariate elementary statistics for a 2D container.
28 * Author: Serge Iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
29 **/
30
35#ifndef STK_STAT_MULTIVARIATE_H
36#define STK_STAT_MULTIVARIATE_H
37
38#include <Sdk.h>
39
41
42namespace STK
43{
44namespace Stat
45{
53template < class Array, class WColVector, typename Type = typename Array::Type >
54class Multivariate: public IRunnerUnsupervised< Array, WColVector>
55{
56 public:
64 Multivariate( Array const* p_data)
66 , nbSamples_(0)
67 , nbVar_(0)
68 , nbMiss_()
69 {}
70
77 Multivariate( Array const& data)
78 : Runner2D(data)
79 , nbSamples_()
80 , nbVar_()
81 , nbMiss_()
82 {}
84 virtual ~Multivariate() {}
86 inline int nbSamples() const {return nbSamples_;}
88 inline int nbVariable() const {return nbVar_;}
93 inline Array1D<int> const& nbMissingSamples() const {return nbMiss_;}
97 inline Array1D<int> const& nbAvailableSamples() const {return nbAvailable_;}
98
100 virtual bool run()
101 {
102 if (!this->p_data_)
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--;}
120 }
121 return true;
122 }
126 virtual bool run( WColVector const& weights)
127 {
128 if (!this->p_data_)
130 return false;
131 }
132 return run();
133 }
134
135 protected:
144};
145
146} // namespace Stat
147
148} // namespace STK
149
150#endif /*STK_STAT_MULTIVARIATE_H*/
A Array2DVector is a one dimensional horizontal container.
#define STKERROR_NO_ARG(Where, Error)
Definition STK_Macros.h:49
This file include all the other header files of the project Sdk.
String msg_error_
String with the last error message.
Definition STK_IRunner.h:96
Abstract class for all classes making unsupervised learning.
Array const * p_data() const
get the data set
Array const * p_data_
A pointer on the original data set.
Derived & resize(Range const &I=RowRange())
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
Computation of the multivariate statistics of a Variable.
IRunnerUnsupervised< Array, WColVector > Runner2D
Multivariate(Array const &data)
Constructor.
virtual ~Multivariate()
virtual destructor.
virtual bool run(WColVector const &weights)
run the estimation of the weighted multivariate statistics.
Array1D< int > nbAvailable_
number of observed data of each variables
Array1D< int > const & nbMissingSamples() const
Number of missing values.
int nbSamples_
number of samples
Multivariate(Array const *p_data)
Constructor.
virtual bool run()
run the estimation of the Multivariate statistics.
Array1D< int > nbMiss_
number of missing data of each variables
int nbVar_
Number of variables.
Array1D< int > const & nbAvailableSamples() const
The namespace STK is the main domain space of the Statistical ToolKit project.
Arithmetic properties of STK fundamental types.