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
44extern "C" {
45#endif
46
47/// @cond EXTERNAL
48
49/**************************************************************************
50 * Gaussian
51 *************************************************************************/
52
53// Gaussian PDF info
54typedef 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// Create a gaussian pdf
72pf_pdf_gaussian_t *pf_pdf_gaussian_alloc(pf_vector_t *x, pf_matrix_t *cx);
73
74// Destroy the pdf
75void pf_pdf_gaussian_free(pf_pdf_gaussian_t *pdf);
76
77// Compute the value of the pdf at some point [z].
78//double pf_pdf_gaussian_value(pf_pdf_gaussian_t *pdf, pf_vector_t z);
79
80// Draw randomly from a zero-mean Gaussian distribution, with standard
81// deviation sigma.
82// We use the polar form of the Box-Muller transformation, explained here:
83// http://www.taygeta.com/random/gaussian.html
84double pf_ran_gaussian(double sigma);
85
86// Generate a sample from the the pdf.
87pf_vector_t pf_pdf_gaussian_sample(pf_pdf_gaussian_t *pdf);
88
89#if 0
90
91/**************************************************************************
92 * Discrete
93 *************************************************************************/
94
95// Discrete PDF info
96typedef struct
97{
98 // The list of discrete probs
99 int prob_count;
100 double *probs;
101
102 // A random number generator
103 gsl_rng *rng;
104
105 // The discrete prob generator
106 gsl_ran_discrete_t *ran;
107
108} pf_pdf_discrete_t;
109
110
111// Create a discrete pdf
112pf_pdf_discrete_t *pf_pdf_discrete_alloc(int count, double *probs);
113
114// Destroy the pdf
115void pf_pdf_discrete_free(pf_pdf_discrete_t *pdf);
116
117// Compute the value of the probability of some element [i]
118double pf_pdf_discrete_value(pf_pdf_discrete_t *pdf, int i);
119
120// Generate a sample from the the pdf.
121int pf_pdf_discrete_sample(pf_pdf_discrete_t *pdf);
122#endif
123
124/// @endcond
125
126#ifdef __cplusplus
127}
128#endif
129
130#endif