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