31 #include <boost/numeric/ublas/vector.hpp>
33 #include <o2scl/convert_units.h>
34 #include <o2scl/interp.h>
35 #include <o2scl/uniform_grid.h>
36 #include <o2scl/table.h>
47 void hdf_output(hdf_file &hf,
o2scl::hist &t, std::string name);
50 #ifndef DOXYGEN_NO_O2NS
215 O2SCL_ERR2(
"Requested binning change in non-empty ",
216 "histogram in hist::set_bin_edges().",
exc_efailed);
220 for(
size_t i=0;i<n;i++)
ubin[i]=v[i];
230 void update(
double x,
double val=1.0);
379 template<
class vec_t>
void set_reps(
size_t n,
const vec_t &v) {
381 std::string s=
"Expected a vector of size "+
itos(
hsize)+
382 " and got a vector of size "+
itos(n)+
" in hist::set_reps().";
388 for(
size_t i=0;i<n;i++)
user_rep[i]=v[i];
422 for(
size_t i=0;i<
hsize;i++) {
438 double deriv(
double x);
444 double integ(
double x,
double y);
473 std::string upper_edges, std::string weights);
486 #ifndef DOXYGEN_NO_O2NS
Interpolation class for pre-specified vector.
interp_vec< ubvector > interp_t
Interpolation typedef.
ubvector ubin
Bin locations (N+1)
size_t get_bin_index(double x) const
Get the index of the bin which holds x.
const double & get_wgt_i(size_t i) const
Return contents of bin with index i.
size_t itype
Interpolation type.
const double & operator[](size_t i) const
Get a reference to the weight for the bin at index i.
double & get_bin_low_i(size_t i)
Get the lower edge of bin of index i.
double get_max_rep()
Get the representative for the bin with maximum weight.
void set_wgt_i(size_t i, double val)
Set contents of bin with index i to value val.
void copy_to_table(table<> &t, std::string reps, std::string lower_edges, std::string upper_edges, std::string weights)
Copy histogram data to a table.
double get_max_wgt() const
Get maximum weight.
void set_wgt(double x, double val)
Set contents of bin for x to value val.
invalid argument supplied by user
const double & get_wgt(double x) const
Return contents of bin for x.
ubvector uwgt
Bin contents (N)
bool extend_rhs
If true, allow abcissae beyond the last bin (default false)
double integ(double x, double y)
Return the integral of the function between x and y.
const ubvector & get_wgts() const
Get a reference to the full y vector.
void is_valid() const
Internal consistency check.
double operator()(double x)
Return the value of the function at x.
size_t size() const
The histogram size.
A one-dimensional histogram class.
ubvector urep
Bin representative values (N)
double get_min_wgt() const
Get minimum weight.
double get_rep_i(size_t i)
Return the representative of bin of index i.
static const size_t rmode_avg
Average lower and upper edge.
double interp(double x)
Return the value of the function at x.
bool extend_lhs
If true, allow abcissae before the first bin (default false)
size_t get_rep_mode() const
Get mode used to compute bin representatives.
size_t get_max_index() const
Get the bin index of the maximum weight.
static const size_t rmode_high
Use upper edge.
double deriv(double x)
Return the derivative of the function at x.
const double & get_bin_high(double x) const
Get the upper edge of bin of index i.
double get_rep(double x)
Return the representative of bin containing x.
void update_i(size_t i, double val=1.0)
Increment bin with index i by value val.
ubvector user_rep
User-defined representative values (N)
#define O2SCL_ERR2(d, d2, n)
Set an error, two-string version.
void set_rep_mode(size_t mode)
Set mode used to compute bin representatives.
void normalize(double new_sum)
Renormalize the weights to fix the integral.
void clear_wgts()
Clear the data, but leave the bins as is.
static const size_t rmode_gmean
Use the geometric mean of the lower and upper edges.
#define O2SCL_ERR(d, n)
Set an error with message d and code n.
double deriv2(double x)
Return the second derivative of the function at x.
double & get_wgt(double x)
Return contents of bin for x.
static const size_t rmode_user
Use user-specified representative.
double & get_bin_low(double x)
Get the lower edge of bin of index i.
hist & operator=(const hist &h)
Copy constructor.
void update(double x, double val=1.0)
Increment bin for x by value val.
double & get_bin_high(double x)
Get the upper edge of bin of index i.
size_t get_min_index() const
Get the bin index of the minimum weight.
size_t rmode
Representative mode.
void set_reps(size_t n, const vec_t &v)
Set the representative x-values for each bin.
size_t hsize
Number of bins.
void create_rep_vec(resize_vec_t &v)
Create a vector filled with the representatives for each bin.
Store data in an O<span style='position: relative; top: 0.3em; font-size: 0.8em'>2</span>scl O$_2$scl...
void set_interp_type(size_t interp_type)
Set the interpolation type.
void set_reps_auto()
Set the representative array according to current rmode (if not in user rep mode) ...
double & operator[](size_t i)
Get a reference to the weight for the bin at index i.
static const size_t rmode_low
Use lower edge.
void set_bin_edges(uniform_grid< double > g)
Set bins from a uniform_grid object.
void allocate(size_t n)
Allocate vectors for a histogram of size n.
const ubvector & get_bins() const
Get a reference to the full vector of bin specifications.
std::string itos(int x)
Convert an integer to a string.
hist()
Create an empty histogram.
double & get_bin_high_i(size_t i)
Get the upper edge of bin of index i.
void hdf_input(hdf_file &hf, o2scl::table< vec_t > &t, std::string name)
Input a o2scl::table object from a hdf_file.
void set_bin_edges(size_t n, const vec_t &v)
Set the bins from a vector.
void clear()
Clear the entire histogram.
const double & get_bin_low(double x) const
Get the lower edge of bin of index i.
double get_min_rep()
Get the representative for the bin with minimum weight.