| 
    PLearn 0.1 
   | 
 
#include <LogOfGaussianDensityKernel.h>


Public Member Functions | |
| LogOfGaussianDensityKernel () | |
| LogOfGaussianDensityKernel (real the_sigma) | |
| virtual string | classname () const | 
| virtual OptionList & | getOptionList () const | 
| virtual OptionMap & | getOptionMap () const | 
| virtual RemoteMethodMap & | getRemoteMethodMap () const | 
| virtual  LogOfGaussianDensityKernel *  | deepCopy (CopiesMap &copies) const | 
| virtual real | evaluate (const Vec &x1, const Vec &x2) const | 
| ** Subclasses must override this method **   | |
Static Public Member Functions | |
| static string | _classname_ () | 
| static OptionList & | _getOptionList_ () | 
| static RemoteMethodMap & | _getRemoteMethodMap_ () | 
| static Object * | _new_instance_for_typemap_ () | 
| static bool | _isa_ (const Object *o) | 
| static void | _static_initialize_ () | 
| static const PPath & | declaringFile () | 
Static Public Attributes | |
| static StaticInitializer | _static_initializer_ | 
Static Protected Member Functions | |
| static void | declareOptions (OptionList &ol) | 
| Declare options (data fields) for the class.   | |
Protected Attributes | |
| real | sigma | 
Private Types | |
| typedef Kernel | inherited | 
computes the log of a GaussianDensityKernel logp = log[ exp(-0.5*norm_2(x1-x2)^2/sigma^2)/(sigma*sqrt(2pi))^n ] = log[ exp(-0.5*norm_2(x1-x2)^2/sigma^2)/exp(log[(sigma*sqrt(2pi))^n]) ] = log[ exp(-0.5*norm_2(x1-x2)^2/sigma^2)/exp(log[(2pi*sigma^2)^(n/2)]) ] = -0.5* [ norm_2(x1-x2)^2/sigma^2 + n*( log(2pi) + log(sigma^2) ) ] where n=x1.length().
Definition at line 60 of file LogOfGaussianDensityKernel.h.
typedef Kernel PLearn::LogOfGaussianDensityKernel::inherited [private] | 
        
Reimplemented from PLearn::Kernel.
Definition at line 62 of file LogOfGaussianDensityKernel.h.
| PLearn::LogOfGaussianDensityKernel::LogOfGaussianDensityKernel | ( | ) |  [inline] | 
        
Definition at line 68 of file LogOfGaussianDensityKernel.h.
: sigma() {}
| PLearn::LogOfGaussianDensityKernel::LogOfGaussianDensityKernel | ( | real | the_sigma | ) |  [inline] | 
        
Definition at line 70 of file LogOfGaussianDensityKernel.h.
: sigma(the_sigma) {}
| string PLearn::LogOfGaussianDensityKernel::_classname_ | ( | ) |  [static] | 
        
Reimplemented from PLearn::Kernel.
Definition at line 49 of file LogOfGaussianDensityKernel.cc.
| OptionList & PLearn::LogOfGaussianDensityKernel::_getOptionList_ | ( | ) |  [static] | 
        
Reimplemented from PLearn::Kernel.
Definition at line 49 of file LogOfGaussianDensityKernel.cc.
| RemoteMethodMap & PLearn::LogOfGaussianDensityKernel::_getRemoteMethodMap_ | ( | ) |  [static] | 
        
Reimplemented from PLearn::Kernel.
Definition at line 49 of file LogOfGaussianDensityKernel.cc.
Reimplemented from PLearn::Kernel.
Definition at line 49 of file LogOfGaussianDensityKernel.cc.
| Object * PLearn::LogOfGaussianDensityKernel::_new_instance_for_typemap_ | ( | ) |  [static] | 
        
Reimplemented from PLearn::Object.
Definition at line 49 of file LogOfGaussianDensityKernel.cc.
| StaticInitializer LogOfGaussianDensityKernel::_static_initializer_ & PLearn::LogOfGaussianDensityKernel::_static_initialize_ | ( | ) |  [static] | 
        
Reimplemented from PLearn::Kernel.
Definition at line 49 of file LogOfGaussianDensityKernel.cc.
| string PLearn::LogOfGaussianDensityKernel::classname | ( | ) |  const [virtual] | 
        
Reimplemented from PLearn::Object.
Definition at line 49 of file LogOfGaussianDensityKernel.cc.
| void PLearn::LogOfGaussianDensityKernel::declareOptions | ( | OptionList & | ol | ) |  [static, protected] | 
        
Declare options (data fields) for the class.
Redefine this in subclasses: call declareOption(...) for each option, and then call inherited::declareOptions(options). Please call the inherited method AT THE END to get the options listed in a consistent order (from most recently defined to least recently defined).
static void MyDerivedClass::declareOptions(OptionList& ol) { declareOption(ol, "inputsize", &MyObject::inputsize_, OptionBase::buildoption, "The size of the input; it must be provided"); declareOption(ol, "weights", &MyObject::weights, OptionBase::learntoption, "The learned model weights"); inherited::declareOptions(ol); }
| ol | List of options that is progressively being constructed for the current class. | 
Reimplemented from PLearn::Kernel.
Definition at line 67 of file LogOfGaussianDensityKernel.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), and sigma.
{
    declareOption(ol, "sigma", &LogOfGaussianDensityKernel::sigma, OptionBase::buildoption,
                  "The width of the Gaussian");
    inherited::declareOptions(ol);
}

| static const PPath& PLearn::LogOfGaussianDensityKernel::declaringFile | ( | ) |  [inline, static] | 
        
Reimplemented from PLearn::Kernel.
Definition at line 73 of file LogOfGaussianDensityKernel.h.
:
    static void declareOptions(OptionList& ol);
| LogOfGaussianDensityKernel * PLearn::LogOfGaussianDensityKernel::deepCopy | ( | CopiesMap & | copies | ) |  const [virtual] | 
        
Reimplemented from PLearn::Kernel.
Definition at line 49 of file LogOfGaussianDensityKernel.cc.
| real PLearn::LogOfGaussianDensityKernel::evaluate | ( | const Vec & | x1, | 
| const Vec & | x2 | ||
| ) |  const [virtual] | 
        
** Subclasses must override this method **
returns K(x1,x2)
Implements PLearn::Kernel.
Definition at line 51 of file LogOfGaussianDensityKernel.cc.
References PLearn::TVec< T >::length(), PLearn::log(), Pi, and PLearn::powdistance().
{ 
    // cerr << "LogOfGaussKernel mu: " << x1 << endl; 
    double sigmasq = sigma*sigma;
    // cerr << "sqnorm_xmu " << powdistance(x1, x2, real(2.0)) << endl;
    // cerr << "sigmasq " << sigmasq << endl;
    double q = powdistance(x1, x2, real(2.0))/sigmasq;
    // cerr << "log of gauss kernel q = " << q << endl; 
    //double logp = -0.5 * ( q + x1.length()*( log(2*M_PI) + log(sigmasq)) ); 
    double logp = -0.5 * ( q + x1.length()*( log(2*Pi) + log(sigmasq)) ); 
    // cerr << "logp = " << logp << endl;
    // exit(0);
    return real(logp);
}

| OptionList & PLearn::LogOfGaussianDensityKernel::getOptionList | ( | ) |  const [virtual] | 
        
Reimplemented from PLearn::Object.
Definition at line 49 of file LogOfGaussianDensityKernel.cc.
| OptionMap & PLearn::LogOfGaussianDensityKernel::getOptionMap | ( | ) |  const [virtual] | 
        
Reimplemented from PLearn::Object.
Definition at line 49 of file LogOfGaussianDensityKernel.cc.
| RemoteMethodMap & PLearn::LogOfGaussianDensityKernel::getRemoteMethodMap | ( | ) |  const [virtual] | 
        
Reimplemented from PLearn::Object.
Definition at line 49 of file LogOfGaussianDensityKernel.cc.
Reimplemented from PLearn::Kernel.
Definition at line 73 of file LogOfGaussianDensityKernel.h.
real PLearn::LogOfGaussianDensityKernel::sigma [protected] | 
        
Definition at line 65 of file LogOfGaussianDensityKernel.h.
Referenced by declareOptions().
 1.7.4