Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AdaptiveScoreHistogram.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file protocols/frag_picker/scores/AdaptiveScoreHistogram.cc
11 /// @brief
12 /// @author Dominik Gront (dgront@chem.uw.edu.pl)
13 
14 // package headers
15 #include <basic/Tracer.hh>
17 
18 #include <cmath>
19 
20 #include <utility/vector1.hh>
21 
22 
23 namespace protocols {
24 namespace frag_picker {
25 namespace scores {
26 
27 static basic::Tracer trAdaptiveScoreHistogram(
28  "fragment.picking.scores.AdaptiveScoreHistogram");
29 
31  bin_size_ = bin_size;
32  is_up_to_date_ = true;
33  Size new_size = (Size)(initial_max_score / bin_size_);
34  data_.resize(new_size);
35 }
36 
38 
40 
41  Size bin_id = (Size)(score / bin_size_);
42  if(data_.size() <= bin_id)
43  data_.resize(bin_id+1);
44  data_[bin_id+1]++;
45  is_up_to_date_ = false;
46 }
47 
49 
50  Size sum = 0;
51  for(Size i=1;i<=data_.size();i++)
52  sum += data_[i];
53 
54  return sum;
55 }
56 
58 
59  if(cumulative_sums_.size() < data_.size()) {
60  cumulative_sums_.resize( data_.size() );
61  is_up_to_date_ = false;
62  }
63 
64  if(!is_up_to_date_) {
65  cumulative_sums_[1] = data_[1];
66  for(Size i=2;i<=data_.size();i++) {
68  }
69  }
70 
71  Size bin_id = (Size)(score / bin_size_);
72  if (bin_id >= cumulative_sums_.size())
73  return 0.0;
74  else
75  return log(cumulative_sums_[bin_id + 1] / (Real) cumulative_sums_[cumulative_sums_.size()]);
76 }
77 
78 }
79 } // frag_picker
80 } // protocols