SHOGUN  4.1.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  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2013 Roman Votyakov
8  * Copyright (C) 2012 Jacob Walker
9  * Copyright (C) 2013 Roman Votyakov
10  *
11  * Adapted from the GPML toolbox, specifically likT.m
12  * http://www.gaussianprocess.org/gpml/code/matlab/doc/
13  */
14 
16 
17 #ifdef HAVE_EIGEN3
18 
25 
26 using namespace shogun;
27 using namespace Eigen;
28 
29 namespace shogun
30 {
31 
32 #ifndef DOXYGEN_SHOULD_SKIP_THIS
33 
35 class CNormalPDF : public CFunction
36 {
37 public:
39  CNormalPDF()
40  {
41  m_mu=0.0;
42  m_sigma=1.0;
43  }
44 
50  CNormalPDF(float64_t mu, float64_t sigma)
51  {
52  m_mu=mu;
53  m_sigma=sigma;
54  }
55 
60  void set_mu(float64_t mu) { m_mu=mu; }
61 
66  void set_sigma(float64_t sigma) { m_sigma=sigma; }
67 
74  virtual float64_t operator() (float64_t x)
75  {
76  return (1.0/(CMath::sqrt(2*CMath::PI)*m_sigma))*
77  CMath::exp(-CMath::sq(x-m_mu)/(2.0*CMath::sq(m_sigma)));
78  }
79 
80 private:
81  /* mean */
82  float64_t m_mu;
83 
84  /* standard deviation */
85  float64_t m_sigma;
86 };
87 
91 class CStudentsTPDF : public CFunction
92 {
93 public:
95  CStudentsTPDF()
96  {
97  m_sigma=1.0;
98  m_mu=0.0;
99  m_nu=3.0;
100  }
101 
108  CStudentsTPDF(float64_t sigma, float64_t nu, float64_t mu)
109  {
110  m_sigma=sigma;
111  m_mu=mu;
112  m_nu=nu;
113  }
114 
119  void set_sigma(float64_t sigma) { m_sigma=sigma; }
120 
125  void set_mu(float64_t mu) { m_mu=mu; }
126 
131  void set_nu(float64_t nu) { m_nu=nu; }
132 
140  virtual float64_t operator() (float64_t x)
141  {
142  float64_t lZ=CStatistics::lgamma((m_nu+1.0)/2.0)-CStatistics::lgamma(m_nu/2.0)-
143  CMath::log(m_nu*CMath::PI*CMath::sq(m_sigma))/2.0;
144  return CMath::exp(lZ-((m_nu+1.0)/2.0)*CMath::log(1.0+CMath::sq(x-m_mu)/
145  (m_nu*CMath::sq(m_sigma))));
146  }
147 
148 private:
150  float64_t m_sigma;
151 
153  float64_t m_mu;
154 
156  float64_t m_nu;
157 };
158 
160 class CProductFunction : public CFunction
161 {
162 public:
168  CProductFunction(CFunction* f, CFunction* g)
169  {
170  SG_REF(f);
171  SG_REF(g);
172  m_f=f;
173  m_g=g;
174  }
175 
176  virtual ~CProductFunction()
177  {
178  SG_UNREF(m_f);
179  SG_UNREF(m_g);
180  }
181 
188  virtual float64_t operator() (float64_t x)
189  {
190  return (*m_f)(x)*(*m_g)(x);
191  }
192 
193 private:
195  CFunction* m_f;
197  CFunction* m_g;
198 };
199 
201 class CLinearFunction : public CFunction
202 {
203 public:
205  CLinearFunction() { }
206 
207  virtual ~CLinearFunction() { }
208 
215  virtual float64_t operator() (float64_t x)
216  {
217  return x;
218  }
219 };
220 
222 class CQuadraticFunction : public CFunction
223 {
224 public:
226  CQuadraticFunction() { }
227 
228  virtual ~CQuadraticFunction() { }
229 
236  virtual float64_t operator() (float64_t x)
237  {
238  return CMath::sq(x);
239  }
240 };
241 
242 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
243 
245 {
246  init();
247 }
248 
250  : CLikelihoodModel()
251 {
252  init();
253  set_sigma(sigma);
255 }
256 
257 void CStudentsTLikelihood::init()
258 {
259  m_log_sigma=0.0;
260  m_log_df=CMath::log(2.0);
261  SG_ADD(&m_log_df, "log_df", "Degrees of freedom in log domain", MS_AVAILABLE, GRADIENT_AVAILABLE);
262  SG_ADD(&m_log_sigma, "log_sigma", "Scale parameter in log domain", MS_AVAILABLE, GRADIENT_AVAILABLE);
263 }
264 
266 {
267 }
268 
270  CLikelihoodModel* lik)
271 {
272  ASSERT(lik!=NULL);
273 
274  if (lik->get_model_type()!=LT_STUDENTST)
275  SG_SERROR("Provided likelihood is not of type CStudentsTLikelihood!\n")
276 
277  SG_REF(lik);
278  return (CStudentsTLikelihood*)lik;
279 }
280 
282  SGVector<float64_t> mu, SGVector<float64_t> s2, const CLabels* lab) const
283 {
284  return SGVector<float64_t>(mu);
285 }
286 
288  SGVector<float64_t> mu, SGVector<float64_t> s2, const CLabels* lab) const
289 {
290  SGVector<float64_t> result(s2);
291  Map<VectorXd> eigen_result(result.vector, result.vlen);
293  if (df<2.0)
294  eigen_result=CMath::INFTY*VectorXd::Ones(result.vlen);
295  else
296  {
297  eigen_result+=CMath::exp(m_log_sigma*2.0)*df/(df-2.0)*
298  VectorXd::Ones(result.vlen);
299  }
300 
301  return result;
302 }
303 
305  SGVector<float64_t> func) const
306 {
307  // check the parameters
308  REQUIRE(lab, "Labels are required (lab should not be NULL)\n")
310  "Labels must be type of CRegressionLabels\n")
311  REQUIRE(lab->get_num_labels()==func.vlen, "Number of labels must match "
312  "length of the function vector\n")
313 
314  Map<VectorXd> eigen_f(func.vector, func.vlen);
315 
316  SGVector<float64_t> r(func.vlen);
317  Map<VectorXd> eigen_r(r.vector, r.vlen);
318 
319  SGVector<float64_t> y=((CRegressionLabels*)lab)->get_labels();
320  Map<VectorXd> eigen_y(y.vector, y.vlen);
321 
323  // compute lZ=log(gamma(df/2+1/2))-log(gamma(df/2))-log(df*pi*sigma^2)/2
324  VectorXd eigen_lZ=(CStatistics::lgamma(df/2.0+0.5)-
325  CStatistics::lgamma(df/2.0)-log(df*CMath::PI*CMath::exp(m_log_sigma*2.0))/2.0)*
326  VectorXd::Ones(r.vlen);
327 
328  // compute log probability: lp=lZ-(df+1)*log(1+(y-f).^2./(df*sigma^2))/2
329  eigen_r=eigen_y-eigen_f;
330  eigen_r=eigen_r.cwiseProduct(eigen_r)/(df*CMath::exp(m_log_sigma*2.0));
331  eigen_r=eigen_lZ-(df+1)*
332  (eigen_r+VectorXd::Ones(r.vlen)).array().log().matrix()/2.0;
333 
334  return r;
335 }
336 
338  const CLabels* lab, SGVector<float64_t> func, index_t i) const
339 {
340  // check the parameters
341  REQUIRE(lab, "Labels are required (lab should not be NULL)\n")
343  "Labels must be type of CRegressionLabels\n")
344  REQUIRE(lab->get_num_labels()==func.vlen, "Number of labels must match "
345  "length of the function vector\n")
346  REQUIRE(i>=1 && i<=3, "Index for derivative should be 1, 2 or 3\n")
347 
348  Map<VectorXd> eigen_f(func.vector, func.vlen);
349 
350  SGVector<float64_t> r(func.vlen);
351  Map<VectorXd> eigen_r(r.vector, r.vlen);
352 
353  SGVector<float64_t> y=((CRegressionLabels*)lab)->get_labels();
354  Map<VectorXd> eigen_y(y.vector, y.vlen);
355 
356  // compute r=y-f, r2=r.^2
357  eigen_r=eigen_y-eigen_f;
358  VectorXd eigen_r2=eigen_r.cwiseProduct(eigen_r);
360 
361  // compute a=(y-f).^2+df*sigma^2
362  VectorXd a=eigen_r2+VectorXd::Ones(r.vlen)*df*CMath::exp(m_log_sigma*2.0);
363 
364  if (i==1)
365  {
366  // compute first derivative of log probability wrt f:
367  // dlp=(df+1)*(y-f)./a
368  eigen_r=(df+1)*eigen_r.cwiseQuotient(a);
369  }
370  else if (i==2)
371  {
372  // compute second derivative of log probability wrt f:
373  // d2lp=(df+1)*((y-f)^2-df*sigma^2)./a.^2
374  VectorXd b=eigen_r2-VectorXd::Ones(r.vlen)*df*CMath::exp(m_log_sigma*2.0);
375 
376  eigen_r=(df+1)*b.cwiseQuotient(a.cwiseProduct(a));
377  }
378  else if (i==3)
379  {
380  // compute third derivative of log probability wrt f:
381  // d3lp=(f+1)*2*(y-f).*((y-f)^2-3*f*sigma^2)./a.^3
382  VectorXd c=eigen_r2-VectorXd::Ones(r.vlen)*3*df*CMath::exp(m_log_sigma*2.0);
383  VectorXd a2=a.cwiseProduct(a);
384 
385  eigen_r=(df+1)*2*eigen_r.cwiseProduct(c).cwiseQuotient(
386  a2.cwiseProduct(a));
387  }
388 
389  return r;
390 }
391 
393  SGVector<float64_t> func, const TParameter* param) const
394 {
395  // check the parameters
396  REQUIRE(lab, "Labels are required (lab should not be NULL)\n")
398  "Labels must be type of CRegressionLabels\n")
399  REQUIRE(lab->get_num_labels()==func.vlen, "Number of labels must match "
400  "length of the function vector\n")
401 
402  SGVector<float64_t> r(func.vlen);
403  Map<VectorXd> eigen_r(r.vector, r.vlen);
404 
405  Map<VectorXd> eigen_f(func.vector, func.vlen);
406 
407  SGVector<float64_t> y=((CRegressionLabels*)lab)->get_labels();
408  Map<VectorXd> eigen_y(y.vector, y.vlen);
409 
410  // compute r=y-f and r2=(y-f).^2
411  eigen_r=eigen_y-eigen_f;
412  VectorXd eigen_r2=eigen_r.cwiseProduct(eigen_r);
414 
415  if (!strcmp(param->m_name, "log_df"))
416  {
417  // compute derivative of log probability wrt df:
418  // lp_ddf=df*(dloggamma(df/2+1/2)-dloggamma(df/2))/2-1/2-
419  // df*log(1+r2/(df*sigma^2))/2 +(df/2+1/2)*r2./(df*sigma^2+r2)
420  eigen_r=(df*(CStatistics::dlgamma(df*0.5+0.5)-
421  CStatistics::dlgamma(df*0.5))*0.5-0.5)*VectorXd::Ones(r.vlen);
422 
423  eigen_r-=df*(VectorXd::Ones(r.vlen)+
424  eigen_r2/(df*CMath::exp(m_log_sigma*2.0))).array().log().matrix()/2.0;
425 
426  eigen_r+=(df/2.0+0.5)*eigen_r2.cwiseQuotient(
427  eigen_r2+VectorXd::Ones(r.vlen)*(df*CMath::exp(m_log_sigma*2.0)));
428 
429  eigen_r*=(1.0-1.0/df);
430 
431  return r;
432  }
433  else if (!strcmp(param->m_name, "log_sigma"))
434  {
435  // compute derivative of log probability wrt sigma:
436  // lp_dsigma=(df+1)*r2./a-1
437  eigen_r=(df+1)*eigen_r2.cwiseQuotient(eigen_r2+
438  VectorXd::Ones(r.vlen)*(df*CMath::exp(m_log_sigma*2.0)));
439  eigen_r-=VectorXd::Ones(r.vlen);
440 
441  return r;
442  }
443 
444  return SGVector<float64_t>();
445 }
446 
448  SGVector<float64_t> func, const TParameter* param) const
449 {
450  // check the parameters
451  REQUIRE(lab, "Labels are required (lab should not be NULL)\n")
453  "Labels must be type of CRegressionLabels\n")
454  REQUIRE(lab->get_num_labels()==func.vlen, "Number of labels must match "
455  "length of the function vector\n")
456 
457  SGVector<float64_t> r(func.vlen);
458  Map<VectorXd> eigen_r(r.vector, r.vlen);
459 
460  Map<VectorXd> eigen_f(func.vector, func.vlen);
461 
462  SGVector<float64_t> y=((CRegressionLabels*)lab)->get_labels();
463  Map<VectorXd> eigen_y(y.vector, y.vlen);
464 
465  // compute r=y-f and r2=(y-f).^2
466  eigen_r=eigen_y-eigen_f;
467  VectorXd eigen_r2=eigen_r.cwiseProduct(eigen_r);
469 
470  // compute a=r+sigma^2*df and a2=a.^2
471  VectorXd a=eigen_r2+CMath::exp(m_log_sigma*2.0)*df*VectorXd::Ones(r.vlen);
472  VectorXd a2=a.cwiseProduct(a);
473 
474  if (!strcmp(param->m_name, "log_df"))
475  {
476  // compute derivative of first derivative of log probability wrt df:
477  // dlp_ddf=df*r.*(a-sigma^2*(df+1))./a2
478  eigen_r=df*eigen_r.cwiseProduct(a-CMath::exp(m_log_sigma*2.0)*(df+1.0)*
479  VectorXd::Ones(r.vlen)).cwiseQuotient(a2);
480  eigen_r*=(1.0-1.0/df);
481 
482  return r;
483  }
484  else if (!strcmp(param->m_name, "log_sigma"))
485  {
486  // compute derivative of first derivative of log probability wrt sigma:
487  // dlp_dsigma=-(df+1)*2*df*sigma^2*r./a2
488  eigen_r=-(df+1.0)*2*df*CMath::exp(m_log_sigma*2.0)*
489  eigen_r.cwiseQuotient(a2);
490 
491  return r;
492  }
493 
494  return SGVector<float64_t>();
495 }
496 
498  SGVector<float64_t> func, const TParameter* param) const
499 {
500  // check the parameters
501  REQUIRE(lab, "Labels are required (lab should not be NULL)\n")
503  "Labels must be type of CRegressionLabels\n")
504  REQUIRE(lab->get_num_labels()==func.vlen, "Number of labels must match "
505  "length of the function vector\n")
506 
507  SGVector<float64_t> r(func.vlen);
508  Map<VectorXd> eigen_r(r.vector, r.vlen);
509 
510  Map<VectorXd> eigen_f(func.vector, func.vlen);
511 
512  SGVector<float64_t> y=((CRegressionLabels*)lab)->get_labels();
513  Map<VectorXd> eigen_y(y.vector, y.vlen);
514 
515  // compute r=y-f and r2=(y-f).^2
516  eigen_r=eigen_y-eigen_f;
517  VectorXd eigen_r2=eigen_r.cwiseProduct(eigen_r);
519 
520  // compute a=r+sigma^2*df and a3=a.^3
521  VectorXd a=eigen_r2+CMath::exp(m_log_sigma*2.0)*df*VectorXd::Ones(r.vlen);
522  VectorXd a3=(a.cwiseProduct(a)).cwiseProduct(a);
523 
524  if (!strcmp(param->m_name, "log_df"))
525  {
526  // compute derivative of second derivative of log probability wrt df:
527  // d2lp_ddf=df*(r2.*(r2-3*sigma^2*(1+df))+df*sigma^4)./a3
528  float64_t sigma2=CMath::exp(m_log_sigma*2.0);
529 
530  eigen_r=df*(eigen_r2.cwiseProduct(eigen_r2-3*sigma2*(1.0+df)*
531  VectorXd::Ones(r.vlen))+(df*CMath::sq(sigma2))*VectorXd::Ones(r.vlen));
532  eigen_r=eigen_r.cwiseQuotient(a3);
533 
534  eigen_r*=(1.0-1.0/df);
535 
536  return r;
537  }
538  else if (!strcmp(param->m_name, "log_sigma"))
539  {
540  // compute derivative of second derivative of log probability wrt sigma:
541  // d2lp_dsigma=(df+1)*2*df*sigma^2*(a-4*r2)./a3
542  eigen_r=(df+1.0)*2*df*CMath::exp(m_log_sigma*2.0)*
543  (a-4.0*eigen_r2).cwiseQuotient(a3);
544 
545  return r;
546  }
547 
548  return SGVector<float64_t>();
549 }
550 
552  SGVector<float64_t> mu, SGVector<float64_t> s2, const CLabels* lab) const
553 {
555 
556  if (lab)
557  {
558  REQUIRE((mu.vlen==s2.vlen) && (mu.vlen==lab->get_num_labels()),
559  "Length of the vector of means (%d), length of the vector of "
560  "variances (%d) and number of labels (%d) should be the same\n",
561  mu.vlen, s2.vlen, lab->get_num_labels())
563  "Labels must be type of CRegressionLabels\n")
564 
565  y=((CRegressionLabels*)lab)->get_labels();
566  }
567  else
568  {
569  REQUIRE(mu.vlen==s2.vlen, "Length of the vector of means (%d) and "
570  "length of the vector of variances (%d) should be the same\n",
571  mu.vlen, s2.vlen)
572 
574  y.set_const(1.0);
575  }
576 
577  // create an object of normal pdf
578  CNormalPDF* f=new CNormalPDF();
579 
580  // create an object of Student's t pdf
581  CStudentsTPDF* g=new CStudentsTPDF();
582 
583  g->set_nu(get_degrees_freedom());
584  g->set_sigma(CMath::exp(m_log_sigma));
585 
586  // create an object of product of Student's-t pdf and normal pdf
587  CProductFunction* h=new CProductFunction(f, g);
588  SG_REF(h);
589 
590  // compute probabilities using numerical integration
592 
593  for (index_t i=0; i<mu.vlen; i++)
594  {
595  // set normal pdf parameters
596  f->set_mu(mu[i]);
597  f->set_sigma(CMath::sqrt(s2[i]));
598 
599  // set Stundent's-t pdf parameters
600  g->set_mu(y[i]);
601 
602  // evaluate integral on (-inf, inf)
605  }
606 
607  SG_UNREF(h);
608 
609  for (index_t i=0; i<r.vlen; i++)
610  r[i]=CMath::log(r[i]);
611 
612  return r;
613 }
614 
616  SGVector<float64_t> s2, const CLabels *lab, index_t i) const
617 {
618  // check the parameters
619  REQUIRE(lab, "Labels are required (lab should not be NULL)\n")
620  REQUIRE((mu.vlen==s2.vlen) && (mu.vlen==lab->get_num_labels()),
621  "Length of the vector of means (%d), length of the vector of "
622  "variances (%d) and number of labels (%d) should be the same\n",
623  mu.vlen, s2.vlen, lab->get_num_labels())
624  REQUIRE(i>=0 && i<=mu.vlen, "Index (%d) out of bounds!\n", i)
626  "Labels must be type of CRegressionLabels\n")
627 
628  SGVector<float64_t> y=((CRegressionLabels*)lab)->get_labels();
629 
630  // create an object of normal pdf
631  CNormalPDF* f=new CNormalPDF(mu[i], CMath::sqrt(s2[i]));
632 
633  // create an object of Student's t pdf
634  CStudentsTPDF* g=new CStudentsTPDF(CMath::exp(m_log_sigma), get_degrees_freedom(), y[i]);
635 
636  // create an object of h(x)=N(x|mu,sigma)*t(x|mu,sigma,nu)
637  CProductFunction* h=new CProductFunction(f, g);
638 
639  // create an object of k(x)=x*N(x|mu,sigma)*t(x|mu,sigma,nu)
640  CProductFunction* k=new CProductFunction(new CLinearFunction(), h);
641  SG_REF(k);
642 
643  // compute Z = \int N(x|mu,sigma)*t(x|mu,sigma,nu) dx
646 
647  // compute 1st moment:
648  // E[x] = Z^-1 * \int x*N(x|mu,sigma)*t(x|mu,sigma,nu)dx
651 
652  SG_UNREF(k);
653 
654  return Ex;
655 }
656 
658  SGVector<float64_t> s2, const CLabels *lab, index_t i) const
659 {
660  // check the parameters
661  REQUIRE(lab, "Labels are required (lab should not be NULL)\n")
662  REQUIRE((mu.vlen==s2.vlen) && (mu.vlen==lab->get_num_labels()),
663  "Length of the vector of means (%d), length of the vector of "
664  "variances (%d) and number of labels (%d) should be the same\n",
665  mu.vlen, s2.vlen, lab->get_num_labels())
666  REQUIRE(i>=0 && i<=mu.vlen, "Index (%d) out of bounds!\n", i)
668  "Labels must be type of CRegressionLabels\n")
669 
670  SGVector<float64_t> y=((CRegressionLabels*)lab)->get_labels();
671 
672  // create an object of normal pdf
673  CNormalPDF* f=new CNormalPDF(mu[i], CMath::sqrt(s2[i]));
674 
675  // create an object of Student's t pdf
676  CStudentsTPDF* g=new CStudentsTPDF(CMath::exp(m_log_sigma), get_degrees_freedom(), y[i]);
677 
678  // create an object of h(x)=N(x|mu,sigma)*t(x|mu,sigma,nu)
679  CProductFunction* h=new CProductFunction(f, g);
680 
681  // create an object of k(x)=x*N(x|mu,sigma)*t(x|mu,sigma,nu)
682  CProductFunction* k=new CProductFunction(new CLinearFunction(), h);
683  SG_REF(k);
684 
685  // create an object of p(x)=x^2*N(x|mu,sigma^2)*t(x|mu,sigma,nu)
686  CProductFunction* p=new CProductFunction(new CQuadraticFunction(), h);
687  SG_REF(p);
688 
689  // compute Z = \int N(x|mu,sigma)*t(x|mu,sigma,nu) dx
692 
693  // compute 1st moment:
694  // E[x] = Z^-1 * \int x*N(x|mu,sigma)*t(x|mu,sigma,nu)dx
697 
698  // compute E[x^2] = Z^-1 * \int x^2*N(x|mu,sigma)*t(x|mu,sigma,nu)dx
701 
702  SG_UNREF(k);
703  SG_UNREF(p);
704 
705  // return 2nd moment: Var[x]=E[x^2]-E[x]^2
706  return Ex2-CMath::sq(Ex);
707 }
708 }
709 
710 #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 Machine Learning Toolbox - Documentation