49 #include "clipper_types.h" 56 template<
class T = ftype>
class Range 60 inline Range() { lmin = 999999999; lmax = -999999999; }
63 inline const T&
min()
const {
return lmin; }
64 inline const T&
max()
const {
return lmax; }
65 inline T
range()
const {
return lmax-lmin; }
66 inline void include(
const T& datum )
68 { lmin = (datum<lmin)?datum:lmin; lmax = (datum>lmax)?datum:lmax; }
71 {
return ( datum >= lmin && datum <= lmax ); }
108 inline int size()
const {
return n_; }
127 {
if (
contains(x) ) data[ index_bounded(x) ] += 1.0; }
130 {
if (
contains(x) ) data[ index_bounded(x) ] += w; }
134 inline const ftype&
y(
const int& i )
const {
return data[i]; }
145 std::vector<ftype> data;
170 { init( range, n ); }
174 void init(
const std::vector<ftype>& values,
const int num_ranges = 1000 );
179 void accumulate(
const ftype& value );
181 void accumulate(
const ftype& value,
const ftype& weight );
188 void init(
const int num_ranges = 1000 );
190 void add_pass_1(
const ftype& value );
192 void add_pass_2(
const ftype& value );
Range_sampling(const Range< ftype > &range, const int &n)
constructor: from range and number of samplings
Definition: clipper_stats.h:88
ftype x_min(const int &i) const
return x-value corresponding to bottom of i'th range
Definition: clipper_stats.h:104
const T & min() const
minimum value
Definition: clipper_stats.h:63
ftype x(const int &i) const
return x-value corresponding to centre of i'th range
Definition: clipper_stats.h:102
int size() const
return number of samplings in range
Definition: clipper_stats.h:108
Generic_ordinal()
null constructor
Definition: clipper_stats.h:167
Histogram(const Range< ftype > &range, const int &n)
constructor: from range and sampling
Definition: clipper_stats.h:123
bool contains(const T &datum) const
test if data is within limits ( min <= datum <= max )
Definition: clipper_stats.h:70
int index_bounded(const ftype &x) const
return nearest index to particular x-value (bounded 0...n-1)
Definition: clipper_stats.h:99
Range - upper and lower bounds of some type.
Definition: clipper_stats.h:56
Generic_ordinal(const Range< ftype > &range, const int &n)
constructor: from range and sampling
Definition: clipper_stats.h:169
Range_sampling(const int &n)
constructor: from number of samplings
Definition: clipper_stats.h:86
void accumulate(const ftype &x, const ftype &w)
add specified value to histogram (if it is in range)
Definition: clipper_stats.h:129
Range< ftype > range_
resolution range of data
Definition: clipper_stats.h:195
Histogram()
null constructor
Definition: clipper_stats.h:121
int index(const ftype &x) const
return nearest index to particular x-value
Definition: clipper_stats.h:97
ftype nranges
number of ranges
Definition: clipper_stats.h:194
T range() const
range = max - min
Definition: clipper_stats.h:65
ftype64 ftype
ftype definition for floating point representation
Definition: clipper_precision.h:58
Range(const T &min, const T &max)
constructor
Definition: clipper_stats.h:62
ftype indexf(const ftype &x) const
return fractional posn in counting range from x-value (0..n)
Definition: clipper_stats.h:91
static int intf(const ftype &a)
Truncate-to-integer: int(floor(a))
Definition: clipper_util.h:127
void include(const T &datum)
update limits to include a new datum
Definition: clipper_stats.h:67
std::vector< ftype > hist
histogram of reflections vs resolution
Definition: clipper_stats.h:196
const T & max() const
maximum value
Definition: clipper_stats.h:64
T truncate(const T &datum) const
truncate data to be within range
Definition: clipper_stats.h:73
ftype x(const ftype &i) const
return x-value (0..n) from fractional posn in counting range
Definition: clipper_stats.h:94
Generic ordinal gernerator.
Definition: clipper_stats.h:163
Range()
null constructor
Definition: clipper_stats.h:60
ftype x_max(const int &i) const
return x-value corresponding to top of i'th range
Definition: clipper_stats.h:106
General histogram class.
Definition: clipper_stats.h:117
Range_sampling()
null constructor
Definition: clipper_stats.h:84
static T bound(const T &min, const T &val, const T &max)
bound a value by limits
Definition: clipper_util.h:146
const ftype & y(const int &i) const
return value at index in histogram (Note: no bound check on i)
Definition: clipper_stats.h:134
Range sampling: discrete sampling of a real range.
Definition: clipper_stats.h:80
void accumulate(const ftype &x)
add value to histogram (if it is in range)
Definition: clipper_stats.h:126