SHOGUN  4.1.0
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
StudentsTLikelihood.cpp
浏览该文件的文档.
1 /*
2  * Copyright (c) The Shogun Machine Learning Toolbox
3  * Written (W) 2013 Roman Votyakov
4  * Written (W) 2012 Jacob Walker
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice, this
11  * list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright notice,
13  * this list of conditions and the following disclaimer in the documentation
14  * and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  * The views and conclusions contained in the software and documentation are those
28  * of the authors and should not be interpreted as representing official policies,
29  * either expressed or implied, of the Shogun Development Team.
30  *
31  * Adapted from the GPML toolbox, specifically likT.m
32  * http://www.gaussianprocess.org/gpml/code/matlab/doc/
33  */
35 
36 #ifdef HAVE_EIGEN3
37 
44 
45 using namespace shogun;
46 using namespace Eigen;
47 
48 namespace shogun
49 {
50 
51 #ifndef DOXYGEN_SHOULD_SKIP_THIS
52 
54 class CNormalPDF : public CFunction
55 {
56 public:
58  CNormalPDF()
59  {
60  m_mu=0.0;
61  m_sigma=1.0;
62  }
63 
69  CNormalPDF(float64_t mu, float64_t sigma)
70  {
71  m_mu=mu;
72  m_sigma=sigma;
73  }
74 
79  void set_mu(float64_t mu) { m_mu=mu; }
80 
85  void set_sigma(float64_t sigma) { m_sigma=sigma; }
86 
93  virtual float64_t operator() (float64_t x)
94  {
95  return (1.0/(CMath::sqrt(2*CMath::PI)*m_sigma))*
96  CMath::exp(-CMath::sq(x-m_mu)/(2.0*CMath::sq(m_sigma)));
97  }
98 
99 private:
100  /* mean */
101  float64_t m_mu;
102 
103  /* standard deviation */
104  float64_t m_sigma;
105 };
106 
110 class CStudentsTPDF : public CFunction
111 {
112 public:
114  CStudentsTPDF()
115  {
116  m_sigma=1.0;
117  m_mu=0.0;
118  m_nu=3.0;
119  }
120 
127  CStudentsTPDF(float64_t sigma, float64_t nu, float64_t mu)
128  {
129  m_sigma=sigma;
130  m_mu=mu;
131  m_nu=nu;
132  }
133 
138  void set_sigma(float64_t sigma) { m_sigma=sigma; }
139 
144  void set_mu(float64_t mu) { m_mu=mu; }
145 
150  void set_nu(float64_t nu) { m_nu=nu; }
151 
159  virtual float64_t operator() (float64_t x)
160  {
161  float64_t lZ=CStatistics::lgamma((m_nu+1.0)/2.0)-CStatistics::lgamma(m_nu/2.0)-
162  CMath::log(m_nu*CMath::PI*CMath::sq(m_sigma))/2.0;
163  return CMath::exp(lZ-((m_nu+1.0)/2.0)*CMath::log(1.0+CMath::sq(x-m_mu)/
164  (m_nu*CMath::sq(m_sigma))));
165  }
166 
167 private:
169  float64_t m_sigma;
170 
172  float64_t m_mu;
173 
175  float64_t m_nu;
176 };
177 
179 class CProductFunction : public CFunction
180 {
181 public:
187  CProductFunction(CFunction* f, CFunction* g)
188  {
189  SG_REF(f);
190  SG_REF(g);
191  m_f=f;
192  m_g=g;
193  }
194 
195  virtual ~CProductFunction()
196  {
197  SG_UNREF(m_f);
198  SG_UNREF(m_g);
199  }
200 
207  virtual float64_t operator() (float64_t x)
208  {
209  return (*m_f)(x)*(*m_g)(x);
210  }
211 
212 private:
214  CFunction* m_f;
216  CFunction* m_g;
217 };
218 
220 class CLinearFunction : public CFunction
221 {
222 public:
224  CLinearFunction() { }
225 
226  virtual ~CLinearFunction() { }
227 
234  virtual float64_t operator() (float64_t x)
235  {
236  return x;
237  }
238 };
239 
241 class CQuadraticFunction : public CFunction
242 {
243 public:
245  CQuadraticFunction() { }
246 
247  virtual ~CQuadraticFunction() { }
248 
255  virtual float64_t operator() (float64_t x)
256  {
257  return CMath::sq(x);
258  }
259 };
260 
261 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
262 
264 {
265  init();
266 }
267 
269  : CLikelihoodModel()
270 {
271  init();
272  set_sigma(sigma);
274 }
275 
276 void CStudentsTLikelihood::init()
277 {
278  m_log_sigma=0.0;
279  m_log_df=CMath::log(2.0);
280  SG_ADD(&m_log_df, "log_df", "Degrees of freedom in log domain", MS_AVAILABLE, GRADIENT_AVAILABLE);
281  SG_ADD(&m_log_sigma, "log_sigma", "Scale parameter in log domain", MS_AVAILABLE, GRADIENT_AVAILABLE);
282 }
283 
285 {
286 }
287 
289  CLikelihoodModel* lik)
290 {
291  ASSERT(lik!=NULL);
292 
293  if (lik->get_model_type()!=LT_STUDENTST)
294  SG_SERROR("Provided likelihood is not of type CStudentsTLikelihood!\n")
295 
296  SG_REF(lik);
297  return (CStudentsTLikelihood*)lik;
298 }
299 
301  SGVector<float64_t> mu, SGVector<float64_t> s2, const CLabels* lab) const
302 {
303  return SGVector<float64_t>(mu);
304 }
305 
307  SGVector<float64_t> mu, SGVector<float64_t> s2, const CLabels* lab) const
308 {
309  SGVector<float64_t> result(s2);
310  Map<VectorXd> eigen_result(result.vector, result.vlen);
312  if (df<2.0)
313  eigen_result=CMath::INFTY*VectorXd::Ones(result.vlen);
314  else
315  {
316  eigen_result+=CMath::exp(m_log_sigma*2.0)*df/(df-2.0)*
317  VectorXd::Ones(result.vlen);
318  }
319 
320  return result;
321 }
322 
324  SGVector<float64_t> func) const
325 {
326  // check the parameters
327  REQUIRE(lab, "Labels are required (lab should not be NULL)\n")
329  "Labels must be type of CRegressionLabels\n")
330  REQUIRE(lab->get_num_labels()==func.vlen, "Number of labels must match "
331  "length of the function vector\n")
332 
333  Map<VectorXd> eigen_f(func.vector, func.vlen);
334 
335  SGVector<float64_t> r(func.vlen);
336  Map<VectorXd> eigen_r(r.vector, r.vlen);
337 
338  SGVector<float64_t> y=((CRegressionLabels*)lab)->get_labels();
339  Map<VectorXd> eigen_y(y.vector, y.vlen);
340 
342  // compute lZ=log(gamma(df/2+1/2))-log(gamma(df/2))-log(df*pi*sigma^2)/2
343  VectorXd eigen_lZ=(CStatistics::lgamma(df/2.0+0.5)-
344  CStatistics::lgamma(df/2.0)-log(df*CMath::PI*CMath::exp(m_log_sigma*2.0))/2.0)*
345  VectorXd::Ones(r.vlen);
346 
347  // compute log probability: lp=lZ-(df+1)*log(1+(y-f).^2./(df*sigma^2))/2
348  eigen_r=eigen_y-eigen_f;
349  eigen_r=eigen_r.cwiseProduct(eigen_r)/(df*CMath::exp(m_log_sigma*2.0));
350  eigen_r=eigen_lZ-(df+1)*
351  (eigen_r+VectorXd::Ones(r.vlen)).array().log().matrix()/2.0;
352 
353  return r;
354 }
355 
357  const CLabels* lab, SGVector<float64_t> func, index_t i) const
358 {
359  // check the parameters
360  REQUIRE(lab, "Labels are required (lab should not be NULL)\n")
362  "Labels must be type of CRegressionLabels\n")
363  REQUIRE(lab->get_num_labels()==func.vlen, "Number of labels must match "
364  "length of the function vector\n")
365  REQUIRE(i>=1 && i<=3, "Index for derivative should be 1, 2 or 3\n")
366 
367  Map<VectorXd> eigen_f(func.vector, func.vlen);
368 
369  SGVector<float64_t> r(func.vlen);
370  Map<VectorXd> eigen_r(r.vector, r.vlen);
371 
372  SGVector<float64_t> y=((CRegressionLabels*)lab)->get_labels();
373  Map<VectorXd> eigen_y(y.vector, y.vlen);
374 
375  // compute r=y-f, r2=r.^2
376  eigen_r=eigen_y-eigen_f;
377  VectorXd eigen_r2=eigen_r.cwiseProduct(eigen_r);
379 
380  // compute a=(y-f).^2+df*sigma^2
381  VectorXd a=eigen_r2+VectorXd::Ones(r.vlen)*df*CMath::exp(m_log_sigma*2.0);
382 
383  if (i==1)
384  {
385  // compute first derivative of log probability wrt f:
386  // dlp=(df+1)*(y-f)./a
387  eigen_r=(df+1)*eigen_r.cwiseQuotient(a);
388  }
389  else if (i==2)
390  {
391  // compute second derivative of log probability wrt f:
392  // d2lp=(df+1)*((y-f)^2-df*sigma^2)./a.^2
393  VectorXd b=eigen_r2-VectorXd::Ones(r.vlen)*df*CMath::exp(m_log_sigma*2.0);
394 
395  eigen_r=(df+1)*b.cwiseQuotient(a.cwiseProduct(a));
396  }
397  else if (i==3)
398  {
399  // compute third derivative of log probability wrt f:
400  // d3lp=(f+1)*2*(y-f).*((y-f)^2-3*f*sigma^2)./a.^3
401  VectorXd c=eigen_r2-VectorXd::Ones(r.vlen)*3*df*CMath::exp(m_log_sigma*2.0);
402  VectorXd a2=a.cwiseProduct(a);
403 
404  eigen_r=(df+1)*2*eigen_r.cwiseProduct(c).cwiseQuotient(
405  a2.cwiseProduct(a));
406  }
407 
408  return r;
409 }
410 
412  SGVector<float64_t> func, const TParameter* param) const
413 {
414  // check the parameters
415  REQUIRE(lab, "Labels are required (lab should not be NULL)\n")
417  "Labels must be type of CRegressionLabels\n")
418  REQUIRE(lab->get_num_labels()==func.vlen, "Number of labels must match "
419  "length of the function vector\n")
420 
421  SGVector<float64_t> r(func.vlen);
422  Map<VectorXd> eigen_r(r.vector, r.vlen);
423 
424  Map<VectorXd> eigen_f(func.vector, func.vlen);
425 
426  SGVector<float64_t> y=((CRegressionLabels*)lab)->get_labels();
427  Map<VectorXd> eigen_y(y.vector, y.vlen);
428 
429  // compute r=y-f and r2=(y-f).^2
430  eigen_r=eigen_y-eigen_f;
431  VectorXd eigen_r2=eigen_r.cwiseProduct(eigen_r);
433 
434  if (!strcmp(param->m_name, "log_df"))
435  {
436  // compute derivative of log probability wrt df:
437  // lp_ddf=df*(dloggamma(df/2+1/2)-dloggamma(df/2))/2-1/2-
438  // df*log(1+r2/(df*sigma^2))/2 +(df/2+1/2)*r2./(df*sigma^2+r2)
439  eigen_r=(df*(CStatistics::dlgamma(df*0.5+0.5)-
440  CStatistics::dlgamma(df*0.5))*0.5-0.5)*VectorXd::Ones(r.vlen);
441 
442  eigen_r-=df*(VectorXd::Ones(r.vlen)+
443  eigen_r2/(df*CMath::exp(m_log_sigma*2.0))).array().log().matrix()/2.0;
444 
445  eigen_r+=(df/2.0+0.5)*eigen_r2.cwiseQuotient(
446  eigen_r2+VectorXd::Ones(r.vlen)*(df*CMath::exp(m_log_sigma*2.0)));
447 
448  eigen_r*=(1.0-1.0/df);
449 
450  return r;
451  }
452  else if (!strcmp(param->m_name, "log_sigma"))
453  {
454  // compute derivative of log probability wrt sigma:
455  // lp_dsigma=(df+1)*r2./a-1
456  eigen_r=(df+1)*eigen_r2.cwiseQuotient(eigen_r2+
457  VectorXd::Ones(r.vlen)*(df*CMath::exp(m_log_sigma*2.0)));
458  eigen_r-=VectorXd::Ones(r.vlen);
459 
460  return r;
461  }
462 
463  return SGVector<float64_t>();
464 }
465 
467  SGVector<float64_t> func, const TParameter* param) const
468 {
469  // check the parameters
470  REQUIRE(lab, "Labels are required (lab should not be NULL)\n")
472  "Labels must be type of CRegressionLabels\n")
473  REQUIRE(lab->get_num_labels()==func.vlen, "Number of labels must match "
474  "length of the function vector\n")
475 
476  SGVector<float64_t> r(func.vlen);
477  Map<VectorXd> eigen_r(r.vector, r.vlen);
478 
479  Map<VectorXd> eigen_f(func.vector, func.vlen);
480 
481  SGVector<float64_t> y=((CRegressionLabels*)lab)->get_labels();
482  Map<VectorXd> eigen_y(y.vector, y.vlen);
483 
484  // compute r=y-f and r2=(y-f).^2
485  eigen_r=eigen_y-eigen_f;
486  VectorXd eigen_r2=eigen_r.cwiseProduct(eigen_r);
488 
489  // compute a=r+sigma^2*df and a2=a.^2
490  VectorXd a=eigen_r2+CMath::exp(m_log_sigma*2.0)*df*VectorXd::Ones(r.vlen);
491  VectorXd a2=a.cwiseProduct(a);
492 
493  if (!strcmp(param->m_name, "log_df"))
494  {
495  // compute derivative of first derivative of log probability wrt df:
496  // dlp_ddf=df*r.*(a-sigma^2*(df+1))./a2
497  eigen_r=df*eigen_r.cwiseProduct(a-CMath::exp(m_log_sigma*2.0)*(df+1.0)*
498  VectorXd::Ones(r.vlen)).cwiseQuotient(a2);
499  eigen_r*=(1.0-1.0/df);
500 
501  return r;
502  }
503  else if (!strcmp(param->m_name, "log_sigma"))
504  {
505  // compute derivative of first derivative of log probability wrt sigma:
506  // dlp_dsigma=-(df+1)*2*df*sigma^2*r./a2
507  eigen_r=-(df+1.0)*2*df*CMath::exp(m_log_sigma*2.0)*
508  eigen_r.cwiseQuotient(a2);
509 
510  return r;
511  }
512 
513  return SGVector<float64_t>();
514 }
515 
517  SGVector<float64_t> func, const TParameter* param) const
518 {
519  // check the parameters
520  REQUIRE(lab, "Labels are required (lab should not be NULL)\n")
522  "Labels must be type of CRegressionLabels\n")
523  REQUIRE(lab->get_num_labels()==func.vlen, "Number of labels must match "
524  "length of the function vector\n")
525 
526  SGVector<float64_t> r(func.vlen);
527  Map<VectorXd> eigen_r(r.vector, r.vlen);
528 
529  Map<VectorXd> eigen_f(func.vector, func.vlen);
530 
531  SGVector<float64_t> y=((CRegressionLabels*)lab)->get_labels();
532  Map<VectorXd> eigen_y(y.vector, y.vlen);
533 
534  // compute r=y-f and r2=(y-f).^2
535  eigen_r=eigen_y-eigen_f;
536  VectorXd eigen_r2=eigen_r.cwiseProduct(eigen_r);
538 
539  // compute a=r+sigma^2*df and a3=a.^3
540  VectorXd a=eigen_r2+CMath::exp(m_log_sigma*2.0)*df*VectorXd::Ones(r.vlen);
541  VectorXd a3=(a.cwiseProduct(a)).cwiseProduct(a);
542 
543  if (!strcmp(param->m_name, "log_df"))
544  {
545  // compute derivative of second derivative of log probability wrt df:
546  // d2lp_ddf=df*(r2.*(r2-3*sigma^2*(1+df))+df*sigma^4)./a3
547  float64_t sigma2=CMath::exp(m_log_sigma*2.0);
548 
549  eigen_r=df*(eigen_r2.cwiseProduct(eigen_r2-3*sigma2*(1.0+df)*
550  VectorXd::Ones(r.vlen))+(df*CMath::sq(sigma2))*VectorXd::Ones(r.vlen));
551  eigen_r=eigen_r.cwiseQuotient(a3);
552 
553  eigen_r*=(1.0-1.0/df);
554 
555  return r;
556  }
557  else if (!strcmp(param->m_name, "log_sigma"))
558  {
559  // compute derivative of second derivative of log probability wrt sigma:
560  // d2lp_dsigma=(df+1)*2*df*sigma^2*(a-4*r2)./a3
561  eigen_r=(df+1.0)*2*df*CMath::exp(m_log_sigma*2.0)*
562  (a-4.0*eigen_r2).cwiseQuotient(a3);
563 
564  return r;
565  }
566 
567  return SGVector<float64_t>();
568 }
569 
571  SGVector<float64_t> mu, SGVector<float64_t> s2, const CLabels* lab) const
572 {
574 
575  if (lab)
576  {
577  REQUIRE((mu.vlen==s2.vlen) && (mu.vlen==lab->get_num_labels()),
578  "Length of the vector of means (%d), length of the vector of "
579  "variances (%d) and number of labels (%d) should be the same\n",
580  mu.vlen, s2.vlen, lab->get_num_labels())
582  "Labels must be type of CRegressionLabels\n")
583 
584  y=((CRegressionLabels*)lab)->get_labels();
585  }
586  else
587  {
588  REQUIRE(mu.vlen==s2.vlen, "Length of the vector of means (%d) and "
589  "length of the vector of variances (%d) should be the same\n",
590  mu.vlen, s2.vlen)
591 
593  y.set_const(1.0);
594  }
595 
596  // create an object of normal pdf
597  CNormalPDF* f=new CNormalPDF();
598 
599  // create an object of Student's t pdf
600  CStudentsTPDF* g=new CStudentsTPDF();
601 
602  g->set_nu(get_degrees_freedom());
603  g->set_sigma(CMath::exp(m_log_sigma));
604 
605  // create an object of product of Student's-t pdf and normal pdf
606  CProductFunction* h=new CProductFunction(f, g);
607  SG_REF(h);
608 
609  // compute probabilities using numerical integration
611 
612  for (index_t i=0; i<mu.vlen; i++)
613  {
614  // set normal pdf parameters
615  f->set_mu(mu[i]);
616  f->set_sigma(CMath::sqrt(s2[i]));
617 
618  // set Stundent's-t pdf parameters
619  g->set_mu(y[i]);
620 
621  // evaluate integral on (-inf, inf)
624  }
625 
626  SG_UNREF(h);
627 
628  for (index_t i=0; i<r.vlen; i++)
629  r[i]=CMath::log(r[i]);
630 
631  return r;
632 }
633 
635  SGVector<float64_t> s2, const CLabels *lab, index_t i) const
636 {
637  // check the parameters
638  REQUIRE(lab, "Labels are required (lab should not be NULL)\n")
639  REQUIRE((mu.vlen==s2.vlen) && (mu.vlen==lab->get_num_labels()),
640  "Length of the vector of means (%d), length of the vector of "
641  "variances (%d) and number of labels (%d) should be the same\n",
642  mu.vlen, s2.vlen, lab->get_num_labels())
643  REQUIRE(i>=0 && i<=mu.vlen, "Index (%d) out of bounds!\n", i)
645  "Labels must be type of CRegressionLabels\n")
646 
647  SGVector<float64_t> y=((CRegressionLabels*)lab)->get_labels();
648 
649  // create an object of normal pdf
650  CNormalPDF* f=new CNormalPDF(mu[i], CMath::sqrt(s2[i]));
651 
652  // create an object of Student's t pdf
653  CStudentsTPDF* g=new CStudentsTPDF(CMath::exp(m_log_sigma), get_degrees_freedom(), y[i]);
654 
655  // create an object of h(x)=N(x|mu,sigma)*t(x|mu,sigma,nu)
656  CProductFunction* h=new CProductFunction(f, g);
657 
658  // create an object of k(x)=x*N(x|mu,sigma)*t(x|mu,sigma,nu)
659  CProductFunction* k=new CProductFunction(new CLinearFunction(), h);
660  SG_REF(k);
661 
662  // compute Z = \int N(x|mu,sigma)*t(x|mu,sigma,nu) dx
665 
666  // compute 1st moment:
667  // E[x] = Z^-1 * \int x*N(x|mu,sigma)*t(x|mu,sigma,nu)dx
670 
671  SG_UNREF(k);
672 
673  return Ex;
674 }
675 
677  SGVector<float64_t> s2, const CLabels *lab, index_t i) const
678 {
679  // check the parameters
680  REQUIRE(lab, "Labels are required (lab should not be NULL)\n")
681  REQUIRE((mu.vlen==s2.vlen) && (mu.vlen==lab->get_num_labels()),
682  "Length of the vector of means (%d), length of the vector of "
683  "variances (%d) and number of labels (%d) should be the same\n",
684  mu.vlen, s2.vlen, lab->get_num_labels())
685  REQUIRE(i>=0 && i<=mu.vlen, "Index (%d) out of bounds!\n", i)
687  "Labels must be type of CRegressionLabels\n")
688 
689  SGVector<float64_t> y=((CRegressionLabels*)lab)->get_labels();
690 
691  // create an object of normal pdf
692  CNormalPDF* f=new CNormalPDF(mu[i], CMath::sqrt(s2[i]));
693 
694  // create an object of Student's t pdf
695  CStudentsTPDF* g=new CStudentsTPDF(CMath::exp(m_log_sigma), get_degrees_freedom(), y[i]);
696 
697  // create an object of h(x)=N(x|mu,sigma)*t(x|mu,sigma,nu)
698  CProductFunction* h=new CProductFunction(f, g);
699 
700  // create an object of k(x)=x*N(x|mu,sigma)*t(x|mu,sigma,nu)
701  CProductFunction* k=new CProductFunction(new CLinearFunction(), h);
702  SG_REF(k);
703 
704  // create an object of p(x)=x^2*N(x|mu,sigma^2)*t(x|mu,sigma,nu)
705  CProductFunction* p=new CProductFunction(new CQuadraticFunction(), h);
706  SG_REF(p);
707 
708  // compute Z = \int N(x|mu,sigma)*t(x|mu,sigma,nu) dx
711 
712  // compute 1st moment:
713  // E[x] = Z^-1 * \int x*N(x|mu,sigma)*t(x|mu,sigma,nu)dx
716 
717  // compute E[x^2] = Z^-1 * \int x^2*N(x|mu,sigma)*t(x|mu,sigma,nu)dx
720 
721  SG_UNREF(k);
722  SG_UNREF(p);
723 
724  // return 2nd moment: Var[x]=E[x^2]-E[x]^2
725  return Ex2-CMath::sq(Ex);
726 }
727 }
728 
729 #endif /* HAVE_EIGEN3 */
virtual SGVector< float64_t > get_predictive_variances(SGVector< float64_t > mu, SGVector< float64_t > s2, const CLabels *lab=NULL) const
virtual ELabelType get_label_type() const =0
Real Labels are real-valued labels.
virtual float64_t get_second_moment(SGVector< float64_t > mu, SGVector< float64_t > s2, const CLabels *lab, index_t i) const
static float64_t lgamma(float64_t x)
Definition: Statistics.h:275
int32_t index_t
Definition: common.h:62
static float64_t integrate_quadgk(CFunction *f, float64_t a, float64_t b, float64_t abs_tol=1e-10, float64_t rel_tol=1e-5, uint32_t max_iter=1000, index_t sn=10)
The class Labels models labels, i.e. class assignments of objects.
Definition: Labels.h:43
static const float64_t INFTY
infinity
Definition: Math.h:2048
virtual SGVector< float64_t > get_second_derivative(const CLabels *lab, SGVector< float64_t > func, const TParameter *param) const
virtual int32_t get_num_labels() const =0
real valued labels (e.g. for regression, classifier outputs)
Definition: LabelTypes.h:22
virtual SGVector< float64_t > get_first_derivative(const CLabels *lab, SGVector< float64_t > func, const TParameter *param) const
static T sq(T x)
Definition: Math.h:450
Definition: SGMatrix.h:20
virtual ELikelihoodModelType get_model_type() const
parameter struct
#define REQUIRE(x,...)
Definition: SGIO.h:206
virtual SGVector< float64_t > get_predictive_means(SGVector< float64_t > mu, SGVector< float64_t > s2, const CLabels *lab=NULL) const
virtual SGVector< float64_t > get_log_probability_f(const CLabels *lab, SGVector< float64_t > func) const
float64_t get_degrees_freedom() const
virtual float64_t get_first_moment(SGVector< float64_t > mu, SGVector< float64_t > s2, const CLabels *lab, index_t i) const
virtual SGVector< float64_t > get_log_probability_derivative_f(const CLabels *lab, SGVector< float64_t > func, index_t i) const
#define SG_REF(x)
Definition: SGObject.h:51
Class of a function of one variable.
Definition: Function.h:22
index_t vlen
Definition: SGVector.h:494
#define ASSERT(x)
Definition: SGIO.h:201
double float64_t
Definition: common.h:50
void set_sigma(float64_t sigma)
Class that models a Student's-t likelihood.
#define SG_UNREF(x)
Definition: SGObject.h:52
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
static float64_t dlgamma(float64_t x)
void set_degrees_freedom(float64_t df)
#define SG_SERROR(...)
Definition: SGIO.h:179
static float64_t exp(float64_t x)
Definition: Math.h:621
static float64_t log(float64_t v)
Definition: Math.h:922
#define SG_ADD(...)
Definition: SGObject.h:81
static CStudentsTLikelihood * obtain_from_generic(CLikelihoodModel *likelihood)
static float32_t sqrt(float32_t x)
Definition: Math.h:459
virtual SGVector< float64_t > get_third_derivative(const CLabels *lab, SGVector< float64_t > func, const TParameter *param) const
The Likelihood model base class.
void set_const(T const_elem)
Definition: SGVector.cpp:152
virtual SGVector< float64_t > get_log_zeroth_moments(SGVector< float64_t > mu, SGVector< float64_t > s2, const CLabels *lab) const
static const float64_t PI
Definition: Math.h:2055

SHOGUN 机器学习工具包 - 项目文档