|
Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages
pf_pdf.hGo to the documentation of this file.00001 00002 /************************************************************************** 00003 * Desc: Useful pdf functions 00004 * Author: Andrew Howard 00005 * Date: 10 Dec 2002 00006 * CVS: $Id: pf_pdf.h,v 1.3 2003/08/09 21:35:36 inspectorg Exp $ 00007 *************************************************************************/ 00008 00009 #ifndef PF_PDF_H 00010 #define PF_PDF_H 00011 00012 #include "pf_vector.h" 00013 00014 #include <gsl/gsl_rng.h> 00015 #include <gsl/gsl_randist.h> 00016 00017 #ifdef __cplusplus 00018 extern "C" { 00019 #endif 00020 00021 /************************************************************************** 00022 * Gaussian 00023 *************************************************************************/ 00024 00025 // Gaussian PDF info 00026 typedef struct 00027 { 00028 // Mean, covariance and inverse covariance 00029 pf_vector_t x; 00030 pf_matrix_t cx; 00031 pf_matrix_t cxi; 00032 double cxdet; 00033 00034 // Decomposed covariance matrix (rotation * diagonal) 00035 pf_matrix_t cr; 00036 pf_vector_t cd; 00037 00038 // A random number generator 00039 gsl_rng *rng; 00040 00041 } pf_pdf_gaussian_t; 00042 00043 00044 // Create a gaussian pdf 00045 pf_pdf_gaussian_t *pf_pdf_gaussian_alloc(pf_vector_t x, pf_matrix_t cx); 00046 00047 // Destroy the pdf 00048 void pf_pdf_gaussian_free(pf_pdf_gaussian_t *pdf); 00049 00050 // Compute the value of the pdf at some point [z]. 00051 double pf_pdf_gaussian_value(pf_pdf_gaussian_t *pdf, pf_vector_t z); 00052 00053 // Generate a sample from the the pdf. 00054 pf_vector_t pf_pdf_gaussian_sample(pf_pdf_gaussian_t *pdf); 00055 00056 00057 /************************************************************************** 00058 * Discrete 00059 *************************************************************************/ 00060 00061 // Discrete PDF info 00062 typedef struct 00063 { 00064 // The list of discrete probs 00065 int prob_count; 00066 double *probs; 00067 00068 // A random number generator 00069 gsl_rng *rng; 00070 00071 // The discrete prob generator 00072 gsl_ran_discrete_t *ran; 00073 00074 } pf_pdf_discrete_t; 00075 00076 00077 // Create a discrete pdf 00078 pf_pdf_discrete_t *pf_pdf_discrete_alloc(int count, double *probs); 00079 00080 // Destroy the pdf 00081 void pf_pdf_discrete_free(pf_pdf_discrete_t *pdf); 00082 00083 // Compute the value of the probability of some element [i] 00084 double pf_pdf_discrete_value(pf_pdf_discrete_t *pdf, int i); 00085 00086 // Generate a sample from the the pdf. 00087 int pf_pdf_discrete_sample(pf_pdf_discrete_t *pdf); 00088 00089 #ifdef __cplusplus 00090 } 00091 #endif 00092 00093 #endif Generated on Tue May 3 14:15:35 2005 for Player by 1.3.6 |