RdbStatsPercentilesMed.cc

00001 // File:  RdbStatsPercentilesMed.cc
00002 // --8<--8<--8<--8<--
00003 //
00004 // Copyright (C) 2006 Smithsonian Astrophysical Observatory
00005 //
00006 // This file is part of rdbstats
00007 //
00008 // rdbstats is free software; you can redistribute it and/or
00009 // modify it under the terms of the GNU General Public License
00010 // as published by the Free Software Foundation; either version 2
00011 // of the License, or (at your option) any later version.
00012 //
00013 // rdbstats is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the 
00020 //       Free Software Foundation, Inc. 
00021 //       51 Franklin Street, Fifth Floor
00022 //       Boston, MA  02110-1301, USA
00023 //
00024 // -->8-->8-->8-->8--
00025 
00026 #include "RdbStatsPercentilesMed.h"
00027 
00028 // The user specified percentiles.  For example: --percentiles 12,34,45
00029 RdbStatsPercentilesMed::RdbStatsPercentilesMed( RDB& irdbtable,
00030                                                 const string& name,
00031                                                 const string& percent_list,
00032                                                 bool implicitquartile )
00033   throw( Exception ) try : RdbStatsPercentiles( irdbtable, name,
00034                                                 percent_list,
00035                                                 implicitquartile ) {
00036 
00037     try {
00038 
00039 #ifdef TRACEFCT
00040       TraceFct tf( "RdbStatsPercentilesMed::RdbStatsPercentilesMed( RDB&, "
00041                    "const string&, const string& ) throw( Exception )" );
00042 #endif
00043 
00044     } catch ( Exception& E ) {
00045 
00046       throw;
00047 
00048     } catch ( exception& e ) {
00049 
00050       throw Exception( e.what( ) );
00051 
00052     }
00053 
00054   } catch ( Exception& E ) {
00055 
00056     // exception thrown by RdbStatsPercentiles class is caught here
00057     throw;
00058 
00059   } catch ( exception& e ) {
00060 
00061     // exception thrown by RdbStatsPercentiles class is caught here
00062     throw Exception( e.what( ) );
00063 
00064   }
00065 
00066 // --quartiles was entered at the command line.
00067 RdbStatsPercentilesMed::RdbStatsPercentilesMed( RDB& irdbtable,
00068                                                 const string& name )
00069   throw( Exception ) try : RdbStatsPercentiles( irdbtable, name ) {
00070 
00071     try {
00072 
00073 #ifdef TRACEFCT
00074       TraceFct tf( "RdbStatsPercentilesMed::RdbStatsPercentilesMed( RDB&, "
00075                    "const string&, const string& ) throw( Exception )" );
00076 #endif
00077 
00078     } catch ( Exception& E ) {
00079 
00080       throw;
00081 
00082     } catch ( exception& e ) {
00083 
00084       throw Exception( e.what( ) );
00085 
00086     }
00087 
00088   } catch ( Exception& E ) {
00089 
00090     // exception thrown by RdbStatsPercentiles class is caught here
00091     throw;
00092 
00093   } catch ( exception& e ) {
00094 
00095     // exception thrown by RdbStatsPercentiles class is caught here
00096     throw Exception( e.what( ) );
00097 
00098   }
00099 
00100 int RdbStatsPercentilesMed::calculate_statistics( ) throw( ) {
00101 
00102 #ifdef TRACEFCT
00103   TraceFct tf( "double RdbStatsPercentilesMed::calculate_statistics( ) "
00104                "throw( )" );
00105 #endif
00106 
00107   // calculate regular-stats and the percentiles.
00108   if ( 0 == this->RdbStatsPercentiles::calculate_statistics( ) )
00109     return 0;
00110 
00111   // normalize the result wrt the median.
00112   double norm_factor = fabs( the_median );
00113   normalize_results( norm_factor );
00114 
00115   return num_n;
00116 
00117 }