Changeset 500
- Timestamp:
- Jan 28, 2006, 5:41:54 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/classifier/ConsensusInputRanker.cc
r485 r500 43 43 ranks[j]=input_rankers_[j].rank(i); 44 44 } 45 medians[i].first = statistics::median (ranks);45 medians[i].first = statistics::median_TMP(ranks); 46 46 medians[i].second = i; 47 47 } -
trunk/lib/statistics/WilcoxonFoldChange.cc
r488 r500 35 35 } 36 36 if (absolute_) 37 return fabs(median (distance));38 return median (distance);37 return fabs(median_TMP(distance)); 38 return median_TMP(distance); 39 39 } 40 40 -
trunk/lib/statistics/utility.cc
r464 r500 5 5 6 6 #include <gsl/gsl_randist.h> 7 7 #include <gsl/gsl_statistics_double.h> 8 8 9 9 namespace theplu { … … 18 18 } 19 19 20 double median(const gslapi::vector& vec, const bool sorted) 21 { 22 if (!sorted){ 23 gslapi::vector vec_copy(vec); 24 vec_copy.sort(); 25 return gsl_stats_median_from_sorted_data (vec_copy.gsl_vector_p()->data, 26 vec_copy.gsl_vector_p()->stride, 27 vec_copy.gsl_vector_p()->size); 28 } 29 return gsl_stats_median_from_sorted_data (vec.gsl_vector_p()->data, 30 vec.gsl_vector_p()->stride, 31 vec.gsl_vector_p()->size); 32 } 33 20 34 }} // of namespace statistics and namespace theplu -
trunk/lib/statistics/utility.h
r464 r500 3 3 #ifndef _theplu_statistics_utility_ 4 4 #define _theplu_statistics_utility_ 5 6 #include <c++_tools/gslapi/vector.h> 5 7 6 8 #include <algorithm> … … 35 37 /// @return \a p'th percentile 36 38 /// 39 /// @note interface will change 40 /// 37 41 template <class T> 38 double percentile (std::vector<T>& vec, double p)42 double percentile_TMP(std::vector<T>& vec, double p) 39 43 { 40 44 if (p==100) … … 52 56 /// values. @return median 53 57 /// 58 /// @note interface will change 59 /// 54 60 template <class T> 55 inline double median (std::vector<T>& v) { return percentile(v,50.0); }61 inline double median_TMP(std::vector<T>& v) { return percentile_TMP(v,50.0); } 56 62 57 63 /// 64 /// Median is defined to be value in the middle. If number of values 65 /// is even median is the average of the two middle values. If @a 66 /// sorted is true, the function assumes vector @a vec to be 67 /// sorted. If @a sorted is false, the vector is copied, the copy 68 /// is sorted, and then used to calculate the median. 69 /// 70 /// @return median 71 /// 72 double median(const gslapi::vector& vec, const bool sorted=true); 73 58 74 }} // of namespace statistics and namespace theplu 59 75 -
trunk/test/statistics_test.cc
r301 r500 15 15 for (unsigned int i=0; i<10; i++) 16 16 data.push_back(static_cast<double>(i)); 17 double m=theplu::statistics::median (data);17 double m=theplu::statistics::median_TMP(data); 18 18 if (m!=4.5) 19 19 return -1;
Note: See TracChangeset
for help on using the changeset viewer.