#ifndef __fpa__Base__Functors__GaussianModel__hxx__ #define __fpa__Base__Functors__GaussianModel__hxx__ // ------------------------------------------------------------------------- template< class _TInput, class _TOutput > typename fpa::Base::Functors::GaussianModel< _TInput, _TOutput >:: TOutput fpa::Base::Functors::GaussianModel< _TInput, _TOutput >:: Evaluate( const TInput& x ) const { double v = double( x ); double d = double( 0 ); if( this->m_N > 1 ) { double N = double( this->m_N ); double m = this->m_S1 / N; double s = ( this->m_S2 - ( ( this->m_S1 * this->m_S1 ) / N ) ) / ( N - double( 1 ) ); if( s > double( 0 ) ) { d = ( v - m ); d *= d; d /= s; d = std::sqrt( d ); if( d <= double( 2 ) ) // 2sigma { this->m_S1 += v; this->m_S2 += v * v; this->m_N += 1; } // fi } else { this->m_S1 += v; this->m_S2 += v * v; this->m_N += 1; } // fi } else { this->m_S1 += v; this->m_S2 += v * v; this->m_N += 1; } // fi std::cout << v << " " << d << std::endl; return( d ); /* TODO TOutput r = TOutput( 0 ); if( this->m_Model->GetNumberOfSamples( ) > this->m_SupportSize ) { r = this->m_Model->SquaredMahalanobis( TOutput( x ) ); if( r <= TOutput( 1 ) ) this->m_Model->AddSample( TOutput( x ) ); } else { this->m_Model->AddSample( TOutput( x ) ); if( this->m_Model->GetNumberOfSamples( ) > 2 ) r = this->m_Model->SquaredMahalanobis( TOutput( x ) ); } // fi if( r < this->m_MinimumCost ) return( this->m_MinimumCost ); else return( r ); */ } // ------------------------------------------------------------------------- template< class _TInput, class _TOutput > fpa::Base::Functors::GaussianModel< _TInput, _TOutput >:: GaussianModel( ) : Superclass( ) /* TODO , m_SupportSize( 30 ), m_MinimumCost( TOutput( 1e-10 ) ) */ { /* TODO this->m_Model = TModel::New( ); */ this->m_S1 = double( 0 ); this->m_S2 = double( 0 ); this->m_N = 0; } // ------------------------------------------------------------------------- template< class _TInput, class _TOutput > fpa::Base::Functors::GaussianModel< _TInput, _TOutput >:: ~GaussianModel( ) { } #endif // __fpa__Base__Functors__GaussianModel__hxx__ // eof - $RCSfile$