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