Logo ROOT  
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"
27#include "TUnuranDiscrDist.h"
28
29struct 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*/
55struct 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*/
84struct 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 */
struct unur_distr UNUR_DISTR
Definition: TUnuran.h:70
TUnuranContDist class describing one dimensional continuous distribution.
double DPdf(double x) const
evaluate the derivative of the pdf.
double Pdf(double x) const
evaluate the Probability Density function.
double Cdf(double x) const
evaluate the integral (cdf) on the domain.
TUnuranDiscrDist class for one dimensional discrete distribution.
double Cdf(int x) const
evaluate the integral (cdf) on the given domain
double Pmf(int x) const
evaluate the distribution (probability mesh function) at the integer value x.
TUnuranMultiContDist class describing multi dimensional continuous distributions.
double Pdf(const double *x) const
evaluate the probability density function, used by UnuRan
double Derivative(const double *x, int icoord) const
evaluate the partial derivative for the given coordinate.
void Gradient(const double *x, double *grad) const
evaluate the gradient vector of the Pdf.
Double_t x[n]
Definition: legend1.C:17
double dist(Rotation3D const &r1, Rotation3D const &r2)
Definition: 3DDistances.cxx:48
Free functions adapter needed by UNURAN for onedimensional continuous distributions.
TUnuranContDist Distribution
static double Cdf(double x, const UNUR_DISTR *dist)
evaluate the Cumulative distribution function, integral of the pdf
static double Pdf(double x, const UNUR_DISTR *dist)
evaluate the probality density function
static double Dpdf(double x, const UNUR_DISTR *dist)
evaluate the derivative of the pdf
Free functions adapter needed by UNURAN for one-dimensional discrete distribution.
TUnuranDiscrDist Distribution
static double Pmf(int x, const UNUR_DISTR *dist)
evaluate the probality mesh function
static double Cdf(int x, const UNUR_DISTR *dist)
evaluate the cumulative function
Free functions adapter needed by UNURAN for multidimensional cont distribution.
static double Pdf(const double *x, UNUR_DISTR *dist)
evaluate the probality density function
static int Dpdf(double *grad, const double *x, UNUR_DISTR *dist)
TUnuranMultiContDist Distribution
static double Pdpdf(const double *x, int coord, UNUR_DISTR *dist)