Fawkes API  Fawkes Development Version
pf_pdf.h
1 
2 /***************************************************************************
3  * pf_pdf.h: Useful pdf functions
4  *
5  * Created: Thu May 24 18:40:53 2012
6  * Copyright 2000 Brian Gerkey
7  * 2000 Kasper Stoy
8  * 2012 Tim Niemueller [www.niemueller.de]
9  ****************************************************************************/
10 
11 /* This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL file in the doc directory.
22  */
23 
24 /* From:
25  * Player - One Hell of a Robot Server (LGPL)
26  * Copyright (C) 2000 Brian Gerkey & Kasper Stoy
27  * gerkey@usc.edu kaspers@robotics.usc.edu
28  */
29 /**************************************************************************
30  * Desc: Useful pdf functions
31  * Author: Andrew Howard
32  * Date: 10 Dec 2002
33  *************************************************************************/
34 
35 #ifndef PF_PDF_H
36 #define PF_PDF_H
37 
38 #include "pf_vector.h"
39 
40 //#include <gsl/gsl_rng.h>
41 //#include <gsl/gsl_randist.h>
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 /// @cond EXTERNAL
48 
49 /**************************************************************************
50  * Gaussian
51  *************************************************************************/
52 
53 // Gaussian PDF info
54 typedef struct
55 {
56  // Mean, covariance and inverse covariance
57  pf_vector_t x;
58  pf_matrix_t cx;
59  //pf_matrix_t cxi;
60  double cxdet;
61 
62  // Decomposed covariance matrix (rotation * diagonal)
63  pf_matrix_t cr;
64  pf_vector_t cd;
65 
66  // A random number generator
67  //gsl_rng *rng;
68 
69 } pf_pdf_gaussian_t;
70 
71 
72 // Create a gaussian pdf
73 pf_pdf_gaussian_t *pf_pdf_gaussian_alloc(pf_vector_t x, pf_matrix_t cx);
74 
75 // Destroy the pdf
76 void pf_pdf_gaussian_free(pf_pdf_gaussian_t *pdf);
77 
78 // Compute the value of the pdf at some point [z].
79 //double pf_pdf_gaussian_value(pf_pdf_gaussian_t *pdf, pf_vector_t z);
80 
81 // Draw randomly from a zero-mean Gaussian distribution, with standard
82 // deviation sigma.
83 // We use the polar form of the Box-Muller transformation, explained here:
84 // http://www.taygeta.com/random/gaussian.html
85 double pf_ran_gaussian(double sigma);
86 
87 // Generate a sample from the the pdf.
88 pf_vector_t pf_pdf_gaussian_sample(pf_pdf_gaussian_t *pdf);
89 
90 
91 #if 0
92 
93 /**************************************************************************
94  * Discrete
95  *************************************************************************/
96 
97 // Discrete PDF info
98 typedef struct
99 {
100  // The list of discrete probs
101  int prob_count;
102  double *probs;
103 
104  // A random number generator
105  gsl_rng *rng;
106 
107  // The discrete prob generator
108  gsl_ran_discrete_t *ran;
109 
110 } pf_pdf_discrete_t;
111 
112 
113 // Create a discrete pdf
114 pf_pdf_discrete_t *pf_pdf_discrete_alloc(int count, double *probs);
115 
116 // Destroy the pdf
117 void pf_pdf_discrete_free(pf_pdf_discrete_t *pdf);
118 
119 // Compute the value of the probability of some element [i]
120 double pf_pdf_discrete_value(pf_pdf_discrete_t *pdf, int i);
121 
122 // Generate a sample from the the pdf.
123 int pf_pdf_discrete_sample(pf_pdf_discrete_t *pdf);
124 #endif
125 
126 /// @endcond
127 
128 #ifdef __cplusplus
129 }
130 #endif
131 
132 #endif