SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
StudentsTLikelihood.cpp
Go to the documentation of this file.
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 
43 
44 using namespace shogun;
45 using namespace Eigen;
46 
47 namespace shogun
48 {
49 
50 #ifndef DOXYGEN_SHOULD_SKIP_THIS
51 
53 class CNormalPDF : public CFunction
54 {
55 public:
57  CNormalPDF()
58  {
59  m_mu=0.0;
60  m_sigma=1.0;
61  }
62 
68  CNormalPDF(float64_t mu, float64_t sigma)
69  {
70  m_mu=mu;
71  m_sigma=sigma;
72  }
73 
78  void set_mu(float64_t mu) { m_mu=mu; }
79 
84  void set_sigma(float64_t sigma) { m_sigma=sigma; }
85 
92  virtual float64_t operator() (float64_t x)
93  {
94  return (1.0/(CMath::sqrt(2*CMath::PI)*m_sigma))*
95  CMath::exp(-CMath::sq(x-m_mu)/(2.0*CMath::sq(m_sigma)));
96  }
97 
98 private:
99  /* mean */
100  float64_t m_mu;
101 
102  /* standard deviation */
103  float64_t m_sigma;
104 };
105 
109 class CStudentsTPDF : public CFunction
110 {
111 public:
113  CStudentsTPDF()
114  {
115  m_sigma=1.0;
116  m_mu=0.0;
117  m_nu=3.0;
118  }
119 
126  CStudentsTPDF(float64_t sigma, float64_t nu, float64_t mu)
127  {
128  m_sigma=sigma;
129  m_mu=mu;
130  m_nu=nu;
131  }
132 
137  void set_sigma(float64_t sigma) { m_sigma=sigma; }
138 
143  void set_mu(float64_t mu) { m_mu=mu; }
144 
149  void set_nu(float64_t nu) { m_nu=nu; }
150 
158  virtual float64_t operator() (float64_t x)
159  {
160  float64_t lZ=CStatistics::lgamma((m_nu+1.0)/2.0)-CStatistics::lgamma(m_nu/2.0)-
161  CMath::log(m_nu*CMath::PI*CMath::sq(m_sigma))/2.0;
162  return CMath::exp(lZ-((m_nu+1.0)/2.0)*CMath::log(1.0+CMath::sq(x-m_mu)/
163  (m_nu*CMath::sq(m_sigma))));
164  }
165 
166 private:
168  float64_t m_sigma;
169 
171  float64_t m_mu;
172 
174  float64_t m_nu;
175 };
176 
178 class CProductFunction : public CFunction
179 {
180 public:
186  CProductFunction(CFunction* f, CFunction* g)
187  {
188  SG_REF(f);
189  SG_REF(g);
190  m_f=f;
191  m_g=g;
192  }
193 
194  virtual ~CProductFunction()
195  {
196  SG_UNREF(m_f);
197  SG_UNREF(m_g);
198  }
199 
206  virtual float64_t operator() (float64_t x)
207  {
208  return (*m_f)(x)*(*m_g)(x);
209  }
210 
211 private:
213  CFunction* m_f;
215  CFunction* m_g;
216 };
217 
219 class CLinearFunction : public CFunction
220 {
221 public:
223  CLinearFunction() { }
224 
225  virtual ~CLinearFunction() { }
226 
233  virtual float64_t operator() (float64_t x)
234  {
235  return x;
236  }
237 };
238 
240 class CQuadraticFunction : public CFunction
241 {
242 public:
244  CQuadraticFunction() { }
245 
246  virtual ~CQuadraticFunction() { }
247 
254  virtual float64_t operator() (float64_t x)
255  {
256  return CMath::sq(x);
257  }
258 };
259 
260 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
261 
263 {
264  init();
265 }
266 
268  : CLikelihoodModel()
269 {
270  init();
271  set_sigma(sigma);
273 }
274 
275 void CStudentsTLikelihood::init()
276 {
277  m_log_sigma=0.0;
278  m_log_df=CMath::log(2.0);
279  SG_ADD(&m_log_df, "log_df", "Degrees of freedom in log domain", MS_AVAILABLE, GRADIENT_AVAILABLE);
280  SG_ADD(&m_log_sigma, "log_sigma", "Scale parameter in log domain", MS_AVAILABLE, GRADIENT_AVAILABLE);
281 }
282 
284 {
285 }
286 
288  CLikelihoodModel* lik)
289 {
290  ASSERT(lik!=NULL);
291 
292  if (lik->get_model_type()!=LT_STUDENTST)
293  SG_SERROR("Provided likelihood is not of type CStudentsTLikelihood!\n")
294 
295  SG_REF(lik);
296  return (CStudentsTLikelihood*)lik;
297 }
298 
300  SGVector<float64_t> mu, SGVector<float64_t> s2, const CLabels* lab) const
301 {
302  return SGVector<float64_t>(mu);
303 }
304 
306  SGVector<float64_t> mu, SGVector<float64_t> s2, const CLabels* lab) const
307 {
308  SGVector<float64_t> result(s2);
309  Map<VectorXd> eigen_result(result.vector, result.vlen);
311  if (df<2.0)
312  eigen_result=CMath::INFTY*VectorXd::Ones(result.vlen);
313  else
314  {
315  eigen_result+=CMath::exp(m_log_sigma*2.0)*df/(df-2.0)*
316  VectorXd::Ones(result.vlen);
317  }
318 
319  return result;
320 }
321 
323  SGVector<float64_t> func) const
324 {
325  // check the parameters
326  REQUIRE(lab, "Labels are required (lab should not be NULL)\n")
328  "Labels must be type of CRegressionLabels\n")
329  REQUIRE(lab->get_num_labels()==func.vlen, "Number of labels must match "
330  "length of the function vector\n")
331 
332  Map<VectorXd> eigen_f(func.vector, func.vlen);
333 
334  SGVector<float64_t> r(func.vlen);
335  Map<VectorXd> eigen_r(r.vector, r.vlen);
336 
337  SGVector<float64_t> y=((CRegressionLabels*)lab)->get_labels();
338  Map<VectorXd> eigen_y(y.vector, y.vlen);
339 
341  // compute lZ=log(gamma(df/2+1/2))-log(gamma(df/2))-log(df*pi*sigma^2)/2
342  VectorXd eigen_lZ=(CStatistics::lgamma(df/2.0+0.5)-
343  CStatistics::lgamma(df/2.0)-log(df*CMath::PI*CMath::exp(m_log_sigma*2.0))/2.0)*
344  VectorXd::Ones(r.vlen);
345 
346  // compute log probability: lp=lZ-(df+1)*log(1+(y-f).^2./(df*sigma^2))/2
347  eigen_r=eigen_y-eigen_f;
348  eigen_r=eigen_r.cwiseProduct(eigen_r)/(df*CMath::exp(m_log_sigma*2.0));
349  eigen_r=eigen_lZ-(df+1)*
350  (eigen_r+VectorXd::Ones(r.vlen)).array().log().matrix()/2.0;
351 
352  return r;
353 }
354 
356  const CLabels* lab, SGVector<float64_t> func, index_t i) const
357 {
358  // check the parameters
359  REQUIRE(lab, "Labels are required (lab should not be NULL)\n")
361  "Labels must be type of CRegressionLabels\n")
362  REQUIRE(lab->get_num_labels()==func.vlen, "Number of labels must match "
363  "length of the function vector\n")
364  REQUIRE(i>=1 && i<=3, "Index for derivative should be 1, 2 or 3\n")
365 
366  Map<VectorXd> eigen_f(func.vector, func.vlen);
367 
368  SGVector<float64_t> r(func.vlen);
369  Map<VectorXd> eigen_r(r.vector, r.vlen);
370 
371  SGVector<float64_t> y=((CRegressionLabels*)lab)->get_labels();
372  Map<VectorXd> eigen_y(y.vector, y.vlen);
373 
374  // compute r=y-f, r2=r.^2
375  eigen_r=eigen_y-eigen_f;
376  VectorXd eigen_r2=eigen_r.cwiseProduct(eigen_r);
378 
379  // compute a=(y-f).^2+df*sigma^2
380  VectorXd a=eigen_r2+VectorXd::Ones(r.vlen)*df*CMath::exp(m_log_sigma*2.0);
381 
382  if (i==1)
383  {
384  // compute first derivative of log probability wrt f:
385  // dlp=(df+1)*(y-f)./a
386  eigen_r=(df+1)*eigen_r.cwiseQuotient(a);
387  }
388  else if (i==2)
389  {
390  // compute second derivative of log probability wrt f:
391  // d2lp=(df+1)*((y-f)^2-df*sigma^2)./a.^2
392  VectorXd b=eigen_r2-VectorXd::Ones(r.vlen)*df*CMath::exp(m_log_sigma*2.0);
393 
394  eigen_r=(df+1)*b.cwiseQuotient(a.cwiseProduct(a));
395  }
396  else if (i==3)
397  {
398  // compute third derivative of log probability wrt f:
399  // d3lp=(f+1)*2*(y-f).*((y-f)^2-3*f*sigma^2)./a.^3
400  VectorXd c=eigen_r2-VectorXd::Ones(r.vlen)*3*df*CMath::exp(m_log_sigma*2.0);
401  VectorXd a2=a.cwiseProduct(a);
402 
403  eigen_r=(df+1)*2*eigen_r.cwiseProduct(c).cwiseQuotient(
404  a2.cwiseProduct(a));
405  }
406 
407  return r;
408 }
409 
411  SGVector<float64_t> func, const TParameter* param) const
412 {
413  // check the parameters
414  REQUIRE(lab, "Labels are required (lab should not be NULL)\n")
416  "Labels must be type of CRegressionLabels\n")
417  REQUIRE(lab->get_num_labels()==func.vlen, "Number of labels must match "
418  "length of the function vector\n")
419 
420  SGVector<float64_t> r(func.vlen);
421  Map<VectorXd> eigen_r(r.vector, r.vlen);
422 
423  Map<VectorXd> eigen_f(func.vector, func.vlen);
424 
425  SGVector<float64_t> y=((CRegressionLabels*)lab)->get_labels();
426  Map<VectorXd> eigen_y(y.vector, y.vlen);
427 
428  // compute r=y-f and r2=(y-f).^2
429  eigen_r=eigen_y-eigen_f;
430  VectorXd eigen_r2=eigen_r.cwiseProduct(eigen_r);
432 
433  if (!strcmp(param->m_name, "log_df"))
434  {
435  // compute derivative of log probability wrt df:
436  // lp_ddf=df*(dloggamma(df/2+1/2)-dloggamma(df/2))/2-1/2-
437  // df*log(1+r2/(df*sigma^2))/2 +(df/2+1/2)*r2./(df*sigma^2+r2)
438  eigen_r=(df*(CStatistics::dlgamma(df*0.5+0.5)-
439  CStatistics::dlgamma(df*0.5))*0.5-0.5)*VectorXd::Ones(r.vlen);
440 
441  eigen_r-=df*(VectorXd::Ones(r.vlen)+
442  eigen_r2/(df*CMath::exp(m_log_sigma*2.0))).array().log().matrix()/2.0;
443 
444  eigen_r+=(df/2.0+0.5)*eigen_r2.cwiseQuotient(
445  eigen_r2+VectorXd::Ones(r.vlen)*(df*CMath::exp(m_log_sigma*2.0)));
446 
447  eigen_r*=(1.0-1.0/df);
448 
449  return r;
450  }
451  else if (!strcmp(param->m_name, "log_sigma"))
452  {
453  // compute derivative of log probability wrt sigma:
454  // lp_dsigma=(df+1)*r2./a-1
455  eigen_r=(df+1)*eigen_r2.cwiseQuotient(eigen_r2+
456  VectorXd::Ones(r.vlen)*(df*CMath::exp(m_log_sigma*2.0)));
457  eigen_r-=VectorXd::Ones(r.vlen);
458 
459  return r;
460  }
461 
462  return SGVector<float64_t>();
463 }
464 
466  SGVector<float64_t> func, const TParameter* param) const
467 {
468  // check the parameters
469  REQUIRE(lab, "Labels are required (lab should not be NULL)\n")
471  "Labels must be type of CRegressionLabels\n")
472  REQUIRE(lab->get_num_labels()==func.vlen, "Number of labels must match "
473  "length of the function vector\n")
474 
475  SGVector<float64_t> r(func.vlen);
476  Map<VectorXd> eigen_r(r.vector, r.vlen);
477 
478  Map<VectorXd> eigen_f(func.vector, func.vlen);
479 
480  SGVector<float64_t> y=((CRegressionLabels*)lab)->get_labels();
481  Map<VectorXd> eigen_y(y.vector, y.vlen);
482 
483  // compute r=y-f and r2=(y-f).^2
484  eigen_r=eigen_y-eigen_f;
485  VectorXd eigen_r2=eigen_r.cwiseProduct(eigen_r);
487 
488  // compute a=r+sigma^2*df and a2=a.^2
489  VectorXd a=eigen_r2+CMath::exp(m_log_sigma*2.0)*df*VectorXd::Ones(r.vlen);
490  VectorXd a2=a.cwiseProduct(a);
491 
492  if (!strcmp(param->m_name, "log_df"))
493  {
494  // compute derivative of first derivative of log probability wrt df:
495  // dlp_ddf=df*r.*(a-sigma^2*(df+1))./a2
496  eigen_r=df*eigen_r.cwiseProduct(a-CMath::exp(m_log_sigma*2.0)*(df+1.0)*
497  VectorXd::Ones(r.vlen)).cwiseQuotient(a2);
498  eigen_r*=(1.0-1.0/df);
499 
500  return r;
501  }
502  else if (!strcmp(param->m_name, "log_sigma"))
503  {
504  // compute derivative of first derivative of log probability wrt sigma:
505  // dlp_dsigma=-(df+1)*2*df*sigma^2*r./a2
506  eigen_r=-(df+1.0)*2*df*CMath::exp(m_log_sigma*2.0)*
507  eigen_r.cwiseQuotient(a2);
508 
509  return r;
510  }
511 
512  return SGVector<float64_t>();
513 }
514 
516  SGVector<float64_t> func, const TParameter* param) const
517 {
518  // check the parameters
519  REQUIRE(lab, "Labels are required (lab should not be NULL)\n")
521  "Labels must be type of CRegressionLabels\n")
522  REQUIRE(lab->get_num_labels()==func.vlen, "Number of labels must match "
523  "length of the function vector\n")
524 
525  SGVector<float64_t> r(func.vlen);
526  Map<VectorXd> eigen_r(r.vector, r.vlen);
527 
528  Map<VectorXd> eigen_f(func.vector, func.vlen);
529 
530  SGVector<float64_t> y=((CRegressionLabels*)lab)->get_labels();
531  Map<VectorXd> eigen_y(y.vector, y.vlen);
532 
533  // compute r=y-f and r2=(y-f).^2
534  eigen_r=eigen_y-eigen_f;
535  VectorXd eigen_r2=eigen_r.cwiseProduct(eigen_r);
537 
538  // compute a=r+sigma^2*df and a3=a.^3
539  VectorXd a=eigen_r2+CMath::exp(m_log_sigma*2.0)*df*VectorXd::Ones(r.vlen);
540  VectorXd a3=(a.cwiseProduct(a)).cwiseProduct(a);
541 
542  if (!strcmp(param->m_name, "log_df"))
543  {
544  // compute derivative of second derivative of log probability wrt df:
545  // d2lp_ddf=df*(r2.*(r2-3*sigma^2*(1+df))+df*sigma^4)./a3
546  float64_t sigma2=CMath::exp(m_log_sigma*2.0);
547 
548  eigen_r=df*(eigen_r2.cwiseProduct(eigen_r2-3*sigma2*(1.0+df)*
549  VectorXd::Ones(r.vlen))+(df*CMath::sq(sigma2))*VectorXd::Ones(r.vlen));
550  eigen_r=eigen_r.cwiseQuotient(a3);
551 
552  eigen_r*=(1.0-1.0/df);
553 
554  return r;
555  }
556  else if (!strcmp(param->m_name, "log_sigma"))
557  {
558  // compute derivative of second derivative of log probability wrt sigma:
559  // d2lp_dsigma=(df+1)*2*df*sigma^2*(a-4*r2)./a3
560  eigen_r=(df+1.0)*2*df*CMath::exp(m_log_sigma*2.0)*
561  (a-4.0*eigen_r2).cwiseQuotient(a3);
562 
563  return r;
564  }
565 
566  return SGVector<float64_t>();
567 }
568 
570  SGVector<float64_t> mu, SGVector<float64_t> s2, const CLabels* lab) const
571 {
573 
574  if (lab)
575  {
576  REQUIRE((mu.vlen==s2.vlen) && (mu.vlen==lab->get_num_labels()),
577  "Length of the vector of means (%d), length of the vector of "
578  "variances (%d) and number of labels (%d) should be the same\n",
579  mu.vlen, s2.vlen, lab->get_num_labels())
581  "Labels must be type of CRegressionLabels\n")
582 
583  y=((CRegressionLabels*)lab)->get_labels();
584  }
585  else
586  {
587  REQUIRE(mu.vlen==s2.vlen, "Length of the vector of means (%d) and "
588  "length of the vector of variances (%d) should be the same\n",
589  mu.vlen, s2.vlen)
590 
592  y.set_const(1.0);
593  }
594 
595  // create an object of normal pdf
596  CNormalPDF* f=new CNormalPDF();
597 
598  // create an object of Student's t pdf
599  CStudentsTPDF* g=new CStudentsTPDF();
600 
601  g->set_nu(get_degrees_freedom());
602  g->set_sigma(CMath::exp(m_log_sigma));
603 
604  // create an object of product of Student's-t pdf and normal pdf
605  CProductFunction* h=new CProductFunction(f, g);
606  SG_REF(h);
607 
608  // compute probabilities using numerical integration
610 
611  for (index_t i=0; i<mu.vlen; i++)
612  {
613  // set normal pdf parameters
614  f->set_mu(mu[i]);
615  f->set_sigma(CMath::sqrt(s2[i]));
616 
617  // set Stundent's-t pdf parameters
618  g->set_mu(y[i]);
619 
620  // evaluate integral on (-inf, inf)
623  }
624 
625  SG_UNREF(h);
626 
627  for (index_t i=0; i<r.vlen; i++)
628  r[i]=CMath::log(r[i]);
629 
630  return r;
631 }
632 
634  SGVector<float64_t> s2, const CLabels *lab, index_t i) const
635 {
636  // check the parameters
637  REQUIRE(lab, "Labels are required (lab should not be NULL)\n")
638  REQUIRE((mu.vlen==s2.vlen) && (mu.vlen==lab->get_num_labels()),
639  "Length of the vector of means (%d), length of the vector of "
640  "variances (%d) and number of labels (%d) should be the same\n",
641  mu.vlen, s2.vlen, lab->get_num_labels())
642  REQUIRE(i>=0 && i<=mu.vlen, "Index (%d) out of bounds!\n", i)
644  "Labels must be type of CRegressionLabels\n")
645 
646  SGVector<float64_t> y=((CRegressionLabels*)lab)->get_labels();
647 
648  // create an object of normal pdf
649  CNormalPDF* f=new CNormalPDF(mu[i], CMath::sqrt(s2[i]));
650 
651  // create an object of Student's t pdf
652  CStudentsTPDF* g=new CStudentsTPDF(CMath::exp(m_log_sigma), get_degrees_freedom(), y[i]);
653 
654  // create an object of h(x)=N(x|mu,sigma)*t(x|mu,sigma,nu)
655  CProductFunction* h=new CProductFunction(f, g);
656 
657  // create an object of k(x)=x*N(x|mu,sigma)*t(x|mu,sigma,nu)
658  CProductFunction* k=new CProductFunction(new CLinearFunction(), h);
659  SG_REF(k);
660 
661  // compute Z = \int N(x|mu,sigma)*t(x|mu,sigma,nu) dx
664 
665  // compute 1st moment:
666  // E[x] = Z^-1 * \int x*N(x|mu,sigma)*t(x|mu,sigma,nu)dx
669 
670  SG_UNREF(k);
671 
672  return Ex;
673 }
674 
676  SGVector<float64_t> s2, const CLabels *lab, index_t i) const
677 {
678  // check the parameters
679  REQUIRE(lab, "Labels are required (lab should not be NULL)\n")
680  REQUIRE((mu.vlen==s2.vlen) && (mu.vlen==lab->get_num_labels()),
681  "Length of the vector of means (%d), length of the vector of "
682  "variances (%d) and number of labels (%d) should be the same\n",
683  mu.vlen, s2.vlen, lab->get_num_labels())
684  REQUIRE(i>=0 && i<=mu.vlen, "Index (%d) out of bounds!\n", i)
686  "Labels must be type of CRegressionLabels\n")
687 
688  SGVector<float64_t> y=((CRegressionLabels*)lab)->get_labels();
689 
690  // create an object of normal pdf
691  CNormalPDF* f=new CNormalPDF(mu[i], CMath::sqrt(s2[i]));
692 
693  // create an object of Student's t pdf
694  CStudentsTPDF* g=new CStudentsTPDF(CMath::exp(m_log_sigma), get_degrees_freedom(), y[i]);
695 
696  // create an object of h(x)=N(x|mu,sigma)*t(x|mu,sigma,nu)
697  CProductFunction* h=new CProductFunction(f, g);
698 
699  // create an object of k(x)=x*N(x|mu,sigma)*t(x|mu,sigma,nu)
700  CProductFunction* k=new CProductFunction(new CLinearFunction(), h);
701  SG_REF(k);
702 
703  // create an object of p(x)=x^2*N(x|mu,sigma^2)*t(x|mu,sigma,nu)
704  CProductFunction* p=new CProductFunction(new CQuadraticFunction(), h);
705  SG_REF(p);
706 
707  // compute Z = \int N(x|mu,sigma)*t(x|mu,sigma,nu) dx
710 
711  // compute 1st moment:
712  // E[x] = Z^-1 * \int x*N(x|mu,sigma)*t(x|mu,sigma,nu)dx
715 
716  // compute E[x^2] = Z^-1 * \int x^2*N(x|mu,sigma)*t(x|mu,sigma,nu)dx
719 
720  SG_UNREF(k);
721  SG_UNREF(p);
722 
723  // return 2nd moment: Var[x]=E[x^2]-E[x]^2
724  return Ex2-CMath::sq(Ex);
725 }
726 }
727 
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:131
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:54
Class of a function of one variable.
Definition: Function.h:22
index_t vlen
Definition: SGVector.h:492
#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:55
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
static float64_t dlgamma(float64_t x)
Definition: Statistics.cpp:558
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:84
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:150
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 Machine Learning Toolbox - Documentation