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_; }
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 );
188 void init(
const int num_ranges = 1000 );
int index_bounded(const ftype &x) const
return nearest index to particular x-value (bounded 0...n-1)
Definition: clipper_stats.h:99
Range_sampling(const Range< ftype > &range, const int &n)
constructor: from range and number of samplings
Definition: clipper_stats.h:88
const Histogram & operator+=(const Histogram &h)
add the contents of two histograms (size must match)
Definition: clipper_stats.cpp:66
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
ftype sum() const
return sum of whole histogram
Definition: clipper_stats.cpp:49
ftype x(const ftype &i) const
return x-value (0..n) from fractional posn in counting range
Definition: clipper_stats.h:94
const T & min() const
minimum value
Definition: clipper_stats.h:63
Range - upper and lower bounds of some type.
Definition: clipper_stats.h:56
void prep_ordinal()
generate the ordinal histogram
Definition: clipper_stats.cpp:118
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
bool contains(const T &datum) const
test if data is within limits ( min <= datum <= max )
Definition: clipper_stats.h:70
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
ftype nranges
number of ranges
Definition: clipper_stats.h:194
int index(const ftype &x) const
return nearest index to particular x-value
Definition: clipper_stats.h:97
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 x_min(const int &i) const
return x-value corresponding to bottom of i'th range
Definition: clipper_stats.h:104
static int intf(const ftype &a)
Truncate-to-integer: int(floor(a))
Definition: clipper_util.h:127
void add_pass_1(const ftype &value)
DEPRECATED: add a value to the distribution (pass 1 of 2)
Definition: clipper_stats.cpp:156
void include(const T &datum)
update limits to include a new datum
Definition: clipper_stats.h:67
ftype x(const int &i) const
return x-value corresponding to centre of i'th range
Definition: clipper_stats.h:102
std::vector< ftype > hist
histogram of reflections vs resolution
Definition: clipper_stats.h:196
int size() const
return number of samplings in range
Definition: clipper_stats.h:108
ftype ordinal(const ftype &value) const
return reflection ordinal
Definition: clipper_stats.cpp:93
const ftype & y(const int &i) const
return value at index in histogram (Note: no bound check on i)
Definition: clipper_stats.h:134
T truncate(const T &datum) const
truncate data to be within range
Definition: clipper_stats.h:73
Generic ordinal gernerator.
Definition: clipper_stats.h:163
ftype x_max(const int &i) const
return x-value corresponding to top of i'th range
Definition: clipper_stats.h:106
Range()
null constructor
Definition: clipper_stats.h:60
General histogram class.
Definition: clipper_stats.h:117
const T & max() const
maximum value
Definition: clipper_stats.h:64
void init(const Range< ftype > &range, const int num_ranges=1000)
initialiser: takes the source range and sampling
Definition: clipper_stats.cpp:76
void accumulate(const ftype &value)
accumulate values to build the distribution
Definition: clipper_stats.cpp:102
ftype indexf(const ftype &x) const
return fractional posn in counting range from x-value (0..n)
Definition: clipper_stats.h:91
Range_sampling()
null constructor
Definition: clipper_stats.h:84
T range() const
range = max - min
Definition: clipper_stats.h:65
void invert()
invert distribution to get value from ordinal
Definition: clipper_stats.cpp:126
void add_pass_2(const ftype &value)
DEPRECATED: add a value to the distribution (pass 2 of 2)
Definition: clipper_stats.cpp:161
static T bound(const T &min, const T &val, const T &max)
bound a value by limits
Definition: clipper_util.h:146
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