Doxygen Source Code Documentation
pdf.h
Go to the documentation of this file.00001 /***************************************************************************** 00002 Major portions of this software are copyrighted by the Medical College 00003 of Wisconsin, 1994-2000, and are released under the Gnu General Public 00004 License, Version 2. See the file README.Copyright for details. 00005 ******************************************************************************/ 00006 00007 /*---------------------------------------------------------------------------*/ 00008 /* 00009 Header file of general purpose routines for input, manipulation, and 00010 output of probability density functions. 00011 00012 File: pdf.h 00013 Author: B. Douglas Ward 00014 Date: 28 January 2000 00015 */ 00016 00017 00018 /*---------------------------------------------------------------------------*/ 00019 /* 00020 Define pdf data structure. 00021 */ 00022 00023 00024 typedef struct pdf 00025 { 00026 int nbin; 00027 float * prob; 00028 float lower_bnd; 00029 float upper_bnd; 00030 float width; 00031 } pdf; 00032 00033 00034 /*---------------------------------------------------------------------------*/ 00035 /* 00036 Routine to print an error message and stop. 00037 */ 00038 00039 void PDF_error (char * message); 00040 00041 00042 /*---------------------------------------------------------------------------*/ 00043 /* 00044 macro to test a malloc-ed pointer for validity 00045 */ 00046 00047 #define PDF_MTEST(ptr) \ 00048 if((ptr)==NULL) \ 00049 ( PDF_error ("Cannot allocate memory") ) 00050 00051 00052 /*---------------------------------------------------------------------------*/ 00053 /* 00054 Initialize pdf data structure. 00055 */ 00056 00057 void PDF_initialize (pdf * p); 00058 00059 00060 /*---------------------------------------------------------------------------*/ 00061 /* 00062 Destroy pdf data structure by deallocating memory. 00063 */ 00064 00065 void PDF_destroy (pdf * p); 00066 00067 00068 /*---------------------------------------------------------------------------*/ 00069 /* 00070 Normalize pdf to have unity area. 00071 */ 00072 00073 void PDF_normalize (pdf * p); 00074 00075 00076 /*---------------------------------------------------------------------------*/ 00077 /* 00078 Create pdf data structure by allocating memory and initializing values. 00079 */ 00080 00081 void PDF_create (int nbin, float * prob, float lower_bnd, float upper_bnd, 00082 pdf * p); 00083 00084 00085 /*---------------------------------------------------------------------------*/ 00086 /* 00087 Copy pdf data structure from p to pc. 00088 */ 00089 00090 void PDF_copy (pdf p, pdf * pc); 00091 00092 00093 /*---------------------------------------------------------------------------*/ 00094 /* 00095 Convert bin number to value of independent variable at center of the bin. 00096 */ 00097 00098 float PDF_ibin_to_xvalue (pdf p, int ibin); 00099 00100 00101 /*---------------------------------------------------------------------------*/ 00102 /* 00103 Convert value of independent variable to bin number. 00104 */ 00105 00106 int PDF_xvalue_to_ibin (pdf p, float xvalue); 00107 00108 00109 /*---------------------------------------------------------------------------*/ 00110 /* 00111 Convert value of independent variable to probability. 00112 */ 00113 00114 float PDF_xvalue_to_pvalue (pdf p, float xvalue); 00115 00116 00117 /*---------------------------------------------------------------------------*/ 00118 /* 00119 Print contents of pdf p to screen. 00120 */ 00121 00122 void PDF_print (pdf p); 00123 00124 00125 /*---------------------------------------------------------------------------*/ 00126 /* 00127 Print contents of string str and pdf p to screen. 00128 */ 00129 00130 void PDF_sprint (char * str, pdf p); 00131 00132 00133 /*---------------------------------------------------------------------------*/ 00134 /* 00135 Write contents of pdf p to specified file. 00136 */ 00137 00138 void PDF_write_file (char * filename, pdf p); 00139 00140 00141 /*---------------------------------------------------------------------------*/ 00142 /* 00143 Simple smoothing of the pdf estimate. 00144 */ 00145 00146 void PDF_smooth (pdf * p); 00147 00148 00149 /*---------------------------------------------------------------------------*/ 00150 /* 00151 Trim the pdf by removing the extreme lower and extreme upper values. 00152 */ 00153 00154 void PDF_trim (float lower_per, float upper_per, pdf * p); 00155 00156 00157 /*---------------------------------------------------------------------------*/ 00158 /* 00159 Determine the range of values in the input short array. 00160 */ 00161 00162 void PDF_short_range (int npts, short * sarray, 00163 short * min_val, short * max_val); 00164 00165 00166 /*---------------------------------------------------------------------------*/ 00167 /* 00168 Determine the range of values in the input float array. 00169 */ 00170 00171 void PDF_float_range (int npts, float * farray, 00172 float * min_val, float * max_val); 00173 00174 00175 /*---------------------------------------------------------------------------*/ 00176 /* 00177 Estimate the pdf corresponding to the input short array. 00178 */ 00179 00180 void PDF_short_to_pdf (int npts, short * sarray, pdf * p); 00181 00182 00183 /*---------------------------------------------------------------------------*/ 00184 /* 00185 Estimate the pdf corresponding to the input float array. 00186 */ 00187 00188 void PDF_float_to_pdf (int npts, float * farray, int num_bins, pdf * p); 00189 00190 00191 /*---------------------------------------------------------------------------*/ 00192 /* 00193 Find extrema of pdf function. 00194 */ 00195 00196 void PDF_find_extrema (pdf p, int * num_min, int * pdf_min, 00197 int * num_max, int * pdf_max); 00198 00199 00200 /*---------------------------------------------------------------------------*/ 00201 /* 00202 Find bimodality of pdf function (if possible). 00203 */ 00204 00205 int PDF_find_bimodal (pdf p, int * gmax, int * wmax); 00206 00207 00208 /*---------------------------------------------------------------------------*/ 00209 00210 00211 00212 00213 00214