STK++ 0.9.13
STK_PenCriterion.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::Model
27 * created on: 22 juil. 2011
28 * Purpose: define the Interface base class ICriterion.
29 * Author: iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
30 *
31 **/
32
36
37#ifndef STK_PENCRITERION_H
38#define STK_PENCRITERION_H
39#include <Sdk.h>
40
41#include "STK_IStatModelBase.h"
42
43namespace STK
44{
51{
52 protected:
54 inline ICriterion() : p_model_(), value_(Arithmetic<Real>::NA()) {}
58 inline ICriterion( IStatModelBase const* p_model)
59 : p_model_(p_model), value_(Arithmetic<Real>::NA()){}
60
63 inline ICriterion( IStatModelBase const& model)
64 : p_model_(&model), value_(Arithmetic<Real>::NA()) {}
65
68 inline ICriterion( ICriterion const& criterion)
69 : p_model_(criterion.p_model_), value_(criterion.value_) {}
70
71 public:
73 inline virtual ~ICriterion() {}
75 inline Real const& value() const { return value_;}
77 inline void setModel( IStatModelBase const* p_model) { p_model_ = p_model;}
79 inline void setModel( IStatModelBase const& model) { p_model_ = &model;}
80
81 protected:
86};
87
98{
99 public:
105 inline AICCriterion( IStatModelBase* const p_model): ICriterion(p_model) {}
109 inline AICCriterion( IStatModelBase const& model): ICriterion(model) {}
113 inline AICCriterion( AICCriterion const& criterion): ICriterion(criterion) {}
115 inline virtual ~AICCriterion() {}
117 inline AICCriterion* clone() const { return new AICCriterion(*this);}
119 virtual bool run();
120};
121
122//* Compute AIC Criterion */
123inline bool AICCriterion::run()
124{
125 if (!p_model_)
127 return false;
128 }
129 value_ = p_model_->computeAIC();
130 return true;
131}
132
143{
144 public:
150 inline BICCriterion( IStatModelBase* const p_model): ICriterion(p_model) {}
154 inline BICCriterion( IStatModelBase const& model): ICriterion(model) {}
158 inline BICCriterion( BICCriterion const& criterion): ICriterion(criterion) {}
160 inline virtual ~BICCriterion() {}
162 inline BICCriterion* clone() const { return new BICCriterion(*this);}
164 virtual bool run();
165};
166
167//* Compute BIC Criterion */
168inline bool BICCriterion::run()
169{
170 if (!p_model_)
172 return false;
173 }
174 value_ = p_model_->computeBIC();
175 return true;
176}
177} // namespace STK
178
179#endif
In this file we define the interface base class IStatModelBase.
#define STKERROR_NO_ARG(Where, Error)
Definition STK_Macros.h:49
This file include all the other header files of the project Sdk.
AICCriterion()
Default Constructor.
virtual ~AICCriterion()
virtual destructor.
AICCriterion(AICCriterion const &criterion)
copy Constructor.
AICCriterion * clone() const
clone pattern
AICCriterion(IStatModelBase const &model)
Constructor.
virtual bool run()
implementation of the virtual method run
AICCriterion(IStatModelBase *const p_model)
Constructor.
BICCriterion(BICCriterion const &criterion)
copy Constructor.
BICCriterion * clone() const
clone pattern
BICCriterion()
Default Constructor.
virtual bool run()
implementation of the virtual method run
BICCriterion(IStatModelBase *const p_model)
Constructor.
BICCriterion(IStatModelBase const &model)
Constructor.
virtual ~BICCriterion()
virtual destructor.
void setModel(IStatModelBase const &model)
ICriterion()
Default Constructor.
virtual ~ICriterion()
Destructor.
Real value_
Computed value of the criterion.
Real const & value() const
void setModel(IStatModelBase const *p_model)
ICriterion(ICriterion const &criterion)
copy Constructor.
ICriterion(IStatModelBase const &model)
Constructor.
ICriterion(IStatModelBase const *p_model)
Constructor.
IStatModelBase const * p_model_
The current statistical model to use.
String msg_error_
String with the last error message.
Definition STK_IRunner.h:96
IRunnerBase()
default constructor
Definition STK_IRunner.h:68
Interface base class for all Statistical Models.
double Real
STK fundamental type of Real values.
The namespace STK is the main domain space of the Statistical ToolKit project.
Arithmetic properties of STK fundamental types.