680 |
11 Oct 06 |
jari |
1 |
#ifndef _theplu_yat_classifier_gaussian_kernel_function_ |
680 |
11 Oct 06 |
jari |
2 |
#define _theplu_yat_classifier_gaussian_kernel_function_ |
33 |
22 Jan 04 |
peter |
3 |
|
616 |
31 Aug 06 |
jari |
// $Id$ |
616 |
31 Aug 06 |
jari |
5 |
|
675 |
10 Oct 06 |
jari |
6 |
/* |
4359 |
23 Aug 23 |
peter |
Copyright (C) 2004, 2005, 2006 Jari Häkkinen, Peter Johansson |
4359 |
23 Aug 23 |
peter |
Copyright (C) 2007 Peter Johansson |
4359 |
23 Aug 23 |
peter |
Copyright (C) 2008 Jari Häkkinen, Peter Johansson |
33 |
22 Jan 04 |
peter |
10 |
|
1437 |
25 Aug 08 |
peter |
This file is part of the yat library, http://dev.thep.lu.se/yat |
675 |
10 Oct 06 |
jari |
12 |
|
675 |
10 Oct 06 |
jari |
The yat library is free software; you can redistribute it and/or |
675 |
10 Oct 06 |
jari |
modify it under the terms of the GNU General Public License as |
1486 |
09 Sep 08 |
jari |
published by the Free Software Foundation; either version 3 of the |
675 |
10 Oct 06 |
jari |
License, or (at your option) any later version. |
675 |
10 Oct 06 |
jari |
17 |
|
675 |
10 Oct 06 |
jari |
The yat library is distributed in the hope that it will be useful, |
675 |
10 Oct 06 |
jari |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
675 |
10 Oct 06 |
jari |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
675 |
10 Oct 06 |
jari |
General Public License for more details. |
675 |
10 Oct 06 |
jari |
22 |
|
675 |
10 Oct 06 |
jari |
You should have received a copy of the GNU General Public License |
1487 |
10 Sep 08 |
jari |
along with yat. If not, see <http://www.gnu.org/licenses/>. |
675 |
10 Oct 06 |
jari |
25 |
*/ |
675 |
10 Oct 06 |
jari |
26 |
|
680 |
11 Oct 06 |
jari |
27 |
#include "KernelFunction.h" |
675 |
10 Oct 06 |
jari |
28 |
|
295 |
29 Apr 05 |
peter |
29 |
#include <cmath> |
295 |
29 Apr 05 |
peter |
30 |
|
42 |
26 Feb 04 |
jari |
31 |
namespace theplu { |
680 |
11 Oct 06 |
jari |
32 |
namespace yat { |
450 |
15 Dec 05 |
peter |
33 |
namespace classifier { |
33 |
22 Jan 04 |
peter |
34 |
|
747 |
11 Feb 07 |
peter |
35 |
class DataLookup1D; |
747 |
11 Feb 07 |
peter |
36 |
|
163 |
22 Sep 04 |
peter |
37 |
/// |
767 |
22 Feb 07 |
peter |
/// @brief Class for Gaussian kernel calculations. |
163 |
22 Sep 04 |
peter |
39 |
/// |
4200 |
19 Aug 22 |
peter |
40 |
|
4200 |
19 Aug 22 |
peter |
41 |
class GaussianKernelFunction : public KernelFunction |
33 |
22 Jan 04 |
peter |
42 |
{ |
4200 |
19 Aug 22 |
peter |
43 |
|
33 |
22 Jan 04 |
peter |
44 |
public: |
67 |
27 Apr 04 |
peter |
45 |
/// |
627 |
05 Sep 06 |
peter |
/// Constructor taking the sigma_ , i.e. the width of the Gaussian,as |
627 |
05 Sep 06 |
peter |
/// input. Default is sigma_ = 1. |
627 |
05 Sep 06 |
peter |
48 |
/// |
33 |
22 Jan 04 |
peter |
49 |
GaussianKernelFunction(double = 1); |
4200 |
19 Aug 22 |
peter |
50 |
|
67 |
27 Apr 04 |
peter |
51 |
/// |
163 |
22 Sep 04 |
peter |
///Destructor |
163 |
22 Sep 04 |
peter |
53 |
/// |
33 |
22 Jan 04 |
peter |
54 |
virtual ~GaussianKernelFunction(void) {}; |
4200 |
19 Aug 22 |
peter |
55 |
|
163 |
22 Sep 04 |
peter |
56 |
/// |
163 |
22 Sep 04 |
peter |
/// returning the scalar product of two vectors in feature space using the |
627 |
05 Sep 06 |
peter |
/// Gaussian kernel. @return \f$ exp(-(x - y)^{2}/\sigma^2) \f$ \n |
345 |
08 Jun 05 |
jari |
59 |
/// |
627 |
05 Sep 06 |
peter |
60 |
double operator()(const DataLookup1D& x, |
4200 |
19 Aug 22 |
peter |
61 |
const DataLookup1D& y) const; |
67 |
27 Apr 04 |
peter |
62 |
|
627 |
05 Sep 06 |
peter |
63 |
/** |
627 |
05 Sep 06 |
peter |
\f$ \exp(-d^2/\sigma^2) \f$ where \f$ d^2 = \sum w_y(x_i-y_i)^2 |
627 |
05 Sep 06 |
peter |
/ \sum w_y * N \f$ |
627 |
05 Sep 06 |
peter |
66 |
**/ |
627 |
05 Sep 06 |
peter |
67 |
double operator()(const DataLookup1D& x, |
4200 |
19 Aug 22 |
peter |
68 |
const DataLookupWeighted1D& y) const; |
627 |
05 Sep 06 |
peter |
69 |
|
627 |
05 Sep 06 |
peter |
70 |
/** |
627 |
05 Sep 06 |
peter |
\f$ \exp(-d^2/\sigma^2) \f$ where \f$ d^2 = \sum w_xw_y(x_i-y_i)^2 |
627 |
05 Sep 06 |
peter |
/ \sum w_xw_y * N \f$ |
627 |
05 Sep 06 |
peter |
73 |
**/ |
627 |
05 Sep 06 |
peter |
74 |
double operator()(const DataLookupWeighted1D& x, |
4200 |
19 Aug 22 |
peter |
75 |
const DataLookupWeighted1D& y) const; |
627 |
05 Sep 06 |
peter |
76 |
|
163 |
22 Sep 04 |
peter |
77 |
private: |
527 |
01 Mar 06 |
peter |
78 |
double sigma2_; |
33 |
22 Jan 04 |
peter |
79 |
|
33 |
22 Jan 04 |
peter |
80 |
}; // class GaussianKernelFunction |
33 |
22 Jan 04 |
peter |
81 |
|
680 |
11 Oct 06 |
jari |
82 |
}}} // of namespace classifier, yat, and theplu |
33 |
22 Jan 04 |
peter |
83 |
|
33 |
22 Jan 04 |
peter |
84 |
#endif |