Logo ROOT   6.10/09
Reference Guide
UnuranDistrAdapter.h
Go to the documentation of this file.
1 // @(#)root/unuran:$Id$
2 // Author: L. Moneta Wed Sep 27 11:22:07 2006
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2006 LCG ROOT Math Team, CERN/PH-SFT *
7  * *
8  * *
9  **********************************************************************/
10 
11 // Header file for class UnuranDistr
12 
13 #ifndef ROOT_Math_UnuranDistr
14 #define ROOT_Math_UnuranDistr
15 
16 #include "unuran.h"
17 #include <iostream>
18 
19 #include <cmath>
20 
21 /**
22  Free functions adapter needed by UNURAN for onedimensional continuous distributions
23 */
24 
25 #include "TUnuranContDist.h"
26 #include "TUnuranMultiContDist.h"
27 #include "TUnuranDiscrDist.h"
28 
29 struct ContDist {
30 
32 
33  /// evaluate the probality density function
34  static double Pdf(double x, const UNUR_DISTR * dist) {
35  const Distribution * func = reinterpret_cast<const Distribution *> ( unur_distr_get_extobj(dist) );
36  return func->Pdf(x);
37  }
38  /// evaluate the derivative of the pdf
39  static double Dpdf(double x, const UNUR_DISTR * dist) {
40  const Distribution * func = reinterpret_cast<const Distribution *> ( unur_distr_get_extobj(dist) );
41  return func->DPdf(x);
42  }
43 
44  /// evaluate the Cumulative distribution function, integral of the pdf
45  static double Cdf(double x, const UNUR_DISTR * dist) {
46  const Distribution * func = reinterpret_cast<const Distribution *> ( unur_distr_get_extobj(dist) );
47  return func->Cdf(x);
48  }
49 
50 };
51 
52 /**
53  Free functions adapter needed by UNURAN for multidimensional cont distribution
54 */
55 struct MultiDist {
56 
58 
59  /// evaluate the probality density function
60  static double Pdf(const double * x, UNUR_DISTR * dist) {
61  const Distribution * func = reinterpret_cast<const Distribution *> ( unur_distr_get_extobj(dist) );
62  return func->Pdf(x);
63  }
64 
65  // evaluate the gradient vector of the pdf
66  static int Dpdf(double * grad, const double * x, UNUR_DISTR * dist) {
67  const Distribution * func = reinterpret_cast<const Distribution *> ( unur_distr_get_extobj(dist) );
68  func->Gradient(x,grad);
69  return 0;
70  }
71 
72  // provides the gradient components separatly (partial derivatives)
73  static double Pdpdf(const double * x, int coord, UNUR_DISTR * dist) {
74  const Distribution * func = reinterpret_cast<const Distribution *> ( unur_distr_get_extobj(dist) );
75  return func->Derivative(x,coord);
76  }
77 
78 };
79 
80 
81 /**
82  Free functions adapter needed by UNURAN for one-dimensional discrete distribution
83 */
84 struct DiscrDist {
85 
87 
88 
89  /// evaluate the probality mesh function
90  static double Pmf(int x, const UNUR_DISTR * dist) {
91  const Distribution * func = reinterpret_cast<const Distribution *> ( unur_distr_get_extobj(dist) );
92  return func->Pmf(x);
93  }
94 
95  /// evaluate the cumulative function
96  static double Cdf(int x, const UNUR_DISTR * dist) {
97  const Distribution * func = reinterpret_cast<const Distribution *> ( unur_distr_get_extobj(dist) );
98  return func->Cdf(x);
99  }
100 
101 };
102 
103 
104 
105 #endif /* ROOT_Math_UnuranDistr */
double Pdf(double x) const
evaluate the Probability Density function.
static double Pdpdf(const double *x, int coord, UNUR_DISTR *dist)
double dist(Rotation3D const &r1, Rotation3D const &r2)
Definition: 3DDistances.cxx:48
TUnuranDiscrDist Distribution
double Pdf(const double *x) const
evaluate the probability density function, used by UnuRan
Free functions adapter needed by UNURAN for multidimensional cont distribution.
static double Cdf(int x, const UNUR_DISTR *dist)
evaluate the cumulative function
Free functions adapter needed by UNURAN for one-dimensional discrete distribution.
static double Pdf(const double *x, UNUR_DISTR *dist)
evaluate the probality density function
TUnuranContDist Distribution
TUnuranMultiContDist Distribution
double Cdf(double x) const
evaluate the integral (cdf) on the domain.
static double Dpdf(double x, const UNUR_DISTR *dist)
evaluate the derivative of the pdf
static int Dpdf(double *grad, const double *x, UNUR_DISTR *dist)
Double_t x[n]
Definition: legend1.C:17
Free functions adapter needed by UNURAN for onedimensional continuous distributions.
double Pmf(int x) const
evaluate the distribution (probability mesh function) at the integer value x.
double DPdf(double x) const
evaluate the derivative of the pdf.
TUnuranDiscrDist class for one dimensional discrete distribution.
static double Pmf(int x, const UNUR_DISTR *dist)
evaluate the probality mesh function
static double Pdf(double x, const UNUR_DISTR *dist)
evaluate the probality density function
TUnuranMultiContDist class describing multi dimensional continuous distributions. ...
static double Cdf(double x, const UNUR_DISTR *dist)
evaluate the Cumulative distribution function, integral of the pdf
double func(double *x, double *p)
Definition: stressTF1.cxx:213
double Cdf(int x) const
evaluate the integral (cdf) on the given domain
TUnuranContDist class describing one dimensional continuous distribution.
double Derivative(const double *x, int icoord) const
evaluate the partial derivative for the given coordinate.
struct unur_distr UNUR_DISTR
Definition: TUnuran.h:70
void Gradient(const double *x, double *grad) const
evaluate the gradient vector of the Pdf.