Fawkes API  Fawkes Development Version
pf_pdf.h
00001 
00002 /***************************************************************************
00003  *  pf_pdf.h: Useful pdf functions
00004  *
00005  *  Created: Thu May 24 18:40:53 2012
00006  *  Copyright  2000  Brian Gerkey
00007  *             2000  Kasper Stoy
00008  *             2012  Tim Niemueller [www.niemueller.de]
00009  ****************************************************************************/
00010 
00011 /*  This program is free software; you can redistribute it and/or modify
00012  *  it under the terms of the GNU General Public License as published by
00013  *  the Free Software Foundation; either version 2 of the License, or
00014  *  (at your option) any later version.
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL file in the doc directory.
00022  */
00023 
00024 /*  From:
00025  *  Player - One Hell of a Robot Server (LGPL)
00026  *  Copyright (C) 2000  Brian Gerkey   &  Kasper Stoy
00027  *                      gerkey@usc.edu    kaspers@robotics.usc.edu
00028  */
00029 /**************************************************************************
00030  * Desc: Useful pdf functions
00031  * Author: Andrew Howard
00032  * Date: 10 Dec 2002
00033  *************************************************************************/
00034 
00035 #ifndef PF_PDF_H
00036 #define PF_PDF_H
00037 
00038 #include "pf_vector.h"
00039 
00040 //#include <gsl/gsl_rng.h>
00041 //#include <gsl/gsl_randist.h>
00042 
00043 #ifdef __cplusplus
00044 extern "C" {
00045 #endif
00046 
00047 /// @cond EXTERNAL
00048 
00049 /**************************************************************************
00050  * Gaussian
00051  *************************************************************************/
00052 
00053 // Gaussian PDF info
00054 typedef struct
00055 {
00056   // Mean, covariance and inverse covariance
00057   pf_vector_t x;
00058   pf_matrix_t cx;
00059   //pf_matrix_t cxi;
00060   double cxdet;
00061 
00062   // Decomposed covariance matrix (rotation * diagonal)
00063   pf_matrix_t cr;
00064   pf_vector_t cd;
00065 
00066   // A random number generator
00067   //gsl_rng *rng;
00068 
00069 } pf_pdf_gaussian_t;
00070 
00071 
00072 // Create a gaussian pdf
00073 pf_pdf_gaussian_t *pf_pdf_gaussian_alloc(pf_vector_t x, pf_matrix_t cx);
00074 
00075 // Destroy the pdf
00076 void pf_pdf_gaussian_free(pf_pdf_gaussian_t *pdf);
00077 
00078 // Compute the value of the pdf at some point [z].
00079 //double pf_pdf_gaussian_value(pf_pdf_gaussian_t *pdf, pf_vector_t z);
00080 
00081 // Draw randomly from a zero-mean Gaussian distribution, with standard
00082 // deviation sigma.
00083 // We use the polar form of the Box-Muller transformation, explained here:
00084 //   http://www.taygeta.com/random/gaussian.html
00085 double pf_ran_gaussian(double sigma);
00086 
00087 // Generate a sample from the the pdf.
00088 pf_vector_t pf_pdf_gaussian_sample(pf_pdf_gaussian_t *pdf);
00089 
00090 
00091 #if 0
00092 
00093 /**************************************************************************
00094  * Discrete
00095  *************************************************************************/
00096 
00097 // Discrete PDF info
00098 typedef struct
00099 {
00100   // The list of discrete probs
00101   int prob_count;
00102   double *probs;
00103 
00104   // A random number generator
00105   gsl_rng *rng;
00106 
00107   // The discrete prob generator
00108   gsl_ran_discrete_t *ran;
00109 
00110 } pf_pdf_discrete_t;
00111 
00112 
00113 // Create a discrete pdf
00114 pf_pdf_discrete_t *pf_pdf_discrete_alloc(int count, double *probs);
00115 
00116 // Destroy the pdf
00117 void pf_pdf_discrete_free(pf_pdf_discrete_t *pdf);
00118 
00119 // Compute the value of the probability of some element [i]
00120 double pf_pdf_discrete_value(pf_pdf_discrete_t *pdf, int i);
00121 
00122 // Generate a sample from the the pdf.
00123 int pf_pdf_discrete_sample(pf_pdf_discrete_t *pdf);
00124 #endif
00125 
00126 /// @endcond
00127 
00128 #ifdef __cplusplus
00129 }
00130 #endif
00131 
00132 #endif