ccstruct/statistc.h

Go to the documentation of this file.
00001 
00020 #ifndef           STATISTC_H
00021 #define           STATISTC_H
00022 
00023 #include          <stdio.h>
00024 #include          "grphics.h"
00025 
00030 class DLLSYM STATS
00031 {
00032   INT32 rangemin;                //min of range
00033   INT32 rangemax;                //max of range
00034   INT32 total_count;             //no of samples
00035   INT32 *buckets;                //array of cells
00036 
00037   public:
00038     STATS(             //constructor
00039           INT32 min,   //min of range
00040           INT32 max);  //max of range
00041     STATS();  //empty for arrays
00042 
00043     ~STATS ();                   //destructor
00044 
00045     bool set_range(             //change range
00046                    INT32 min,   //min of range
00047                    INT32 max);  //max of range
00048 
00049     void clear();  //empty buckets
00050 
00051     void add(               //add sample
00052              INT32 value,   //bucket
00053              INT32 count);  //no to add
00054 
00055     INT32 mode();  //get mode of samples
00056 
00057     float mean();  //get mean of samples
00058 
00059     float sd();  //standard deviation
00060 
00061     float ile(              //percentile
00062               float frac);  //[0,1] for percentil
00063 
00064     INT32 min_bucket();  //Find min
00065 
00066     INT32 max_bucket();  //Find max
00067 
00068     float median();  //get median of samples
00069 
00070     void smooth(                //apply blurring
00071                 INT32 factor);  //filter to stats
00072     INT32 cluster(                     //cluster samples
00073                   float lower,         //thresholds
00074                   float upper,
00075                   float multiple,      //distance threshold
00076                   INT32 max_clusters,  //max no to make
00077                   STATS *clusters);    //array of clusters
00078 
00079     INT32 pile_count(             //access function
00080                      INT32 value  //pile to count
00081                     ) {
00082       return value > rangemin ? (value < rangemax
00083         ? buckets[value -
00084         rangemin] : buckets[rangemax -
00085         rangemin -
00086         1]) : buckets[0];
00087     }
00088 
00089     INT32 get_total() {  //access function
00090       return total_count;        //total of all piles
00091     }
00092 
00093     BOOL8 local_min(  //test local minness
00094                     INT32 x);
00095 
00096     void print(              //print summary/table
00097                FILE *fp,     //file to print on
00098                BOOL8 dump);  //dump whole table
00099 
00100     void short_print(              //print summary/table
00101                      FILE *fp,     //file to print on
00102                      BOOL8 dump);  //dump whole table
00103 
00104     void plot(                 //draw histogram rect
00105               WINDOW window,   //window to draw in
00106               float xorigin,   //origin of histo
00107               float yorigin,   //gram
00108               float xscale,    //size of one unit
00109               float yscale,    //size of one uint
00110               COLOUR colour);  //colour to draw in
00111 
00112     void plotline(                 //draw histogram line
00113                   WINDOW window,   //window to draw in
00114                   float xorigin,   //origin of histo
00115                   float yorigin,   //gram
00116                   float xscale,    //size of one unit
00117                   float yscale,    //size of one uint
00118                   COLOUR colour);  //colour to draw in
00119 };
00120 DLLSYM INT32 choose_nth_item(               //fast median
00121                              INT32 index,   //index to choose
00122                              float *array,  //array of items
00123                              INT32 count    //no of items
00124                             );
00125 DLLSYM INT32 choose_nth_item (   //fast median
00126 INT32 index,                     //index to choose
00127 void *array,                     //array of items
00128 INT32 count,                     //no of items
00129 size_t size,                     //element size
00130                                  //comparator
00131 int (*compar) (const void *, const void *)
00132 );
00133 void swap_entries(               //swap in place
00134                   void *array,   //array of entries
00135                   size_t size,   //size of entry
00136                   INT32 index1,  //entries to swap
00137                   INT32 index2);
00138 #endif

Generated on Wed Feb 28 19:49:08 2007 for Tesseract by  doxygen 1.5.1