Classes | Public Member Functions | List of all members
o2scl::prob_dens_mdim_amr< vec_t, mat_t > Class Template Reference

Probability distribution from an adaptive mesh created using a matrix of points. More...

#include <prob_dens_mdim_amr.h>

Inheritance diagram for o2scl::prob_dens_mdim_amr< vec_t, mat_t >:
o2scl::prob_dens_mdim< std::vector< double > >

Detailed Description

template<class vec_t = std::vector<double>, class mat_t = const_matrix_view_table<vec_t>>
class o2scl::prob_dens_mdim_amr< vec_t, mat_t >

Note
This class is experimental.
Idea for Future:
The storage required by the mesh is larger than necessary, and could be replaced by a tree-like structure which uses less storage, but that might demand longer lookup times.

Definition at line 51 of file prob_dens_mdim_amr.h.

Classes

class  hypercube
 A hypercube class for o2scl::prob_dens_mdim_amr. More...
 

Public Member Functions

 prob_dens_mdim_amr ()
 Create an empty probability distribution.
 
 prob_dens_mdim_amr (vec_t &l, vec_t &h)
 Initialize a probability distribution from the corners.
 
- Public Member Functions inherited from o2scl::prob_dens_mdim< std::vector< double > >
virtual size_t dim () const
 Return the dimensionality.
 
virtual double pdf (const std::vector< double > &x) const
 The normalized density.
 
virtual double log_pdf (const std::vector< double > &x) const
 The log of the normalized density.
 
virtual void operator() (std::vector< double > &x) const
 Sample the distribution.
 

Dimension choice setting

int dim_choice
 Method for choosing dimension to slice.
 
o2scl::rng_gsl rg
 Internal random number generator.
 
bool allow_resampling
 Desc.
 
size_t n_dim
 Number of dimensions.
 
vec_t low
 Corner of smallest values.
 
vec_t high
 Corner of largest values.
 
vec_t scale
 Vector of length scales.
 
std::vector< hypercubemesh
 Mesh stored as an array of hypercubes.
 
int verbose
 Verbosity parameter.
 
static const int max_variance =1
 Choose dimension with maximum variance.
 
static const int user_scale =2
 Choose dimension with maximum variance with user-specified scale.
 
static const int random =3
 Choose randomly.
 
void two_indices_to_density (size_t i, size_t j, table3d &t3d, std::string slice)
 Convert two indices to a density in a o2scl::table3d object. More...
 
void clear ()
 Clear everything and set the dimensionality to zero.
 
void clear_mesh ()
 Clear the mesh, leaving the lower and upper limits and the scales unchanged.
 
void copy_to_vectors (size_t &nd, size_t &dc, size_t &ms, std::vector< double > &data, std::vector< size_t > &insides)
 Copy the object data to three size_t numbers and two vectors. More...
 
void set_from_vectors (size_t &nd, size_t &dc, size_t &ms, const std::vector< double > &data, const std::vector< size_t > &insides)
 Set the object from data specified as three size_t numbers and a set of two vectors. More...
 
void set (vec_t &l, vec_t &h)
 Set the mesh limits. More...
 
template<class vec2_t >
void set_scale (vec2_t &v)
 Set scales for dimension choice.
 
void insert (size_t ir, mat_t &m, bool log_mode=false)
 Insert point at row ir, creating a new hypercube for the new point.
 
void initial_parse (mat_t &m, bool log_mode=false)
 Parse the matrix m, creating a new hypercube for every point.
 
void initial_parse_new (mat_t &m)
 Parse the matrix m, creating a new hypercube for every point, ensuring hypercubes are more optimally arranged. More...
 
void weight_is_inv_volume ()
 Set the weight in each hypercube equal to the inverse of the volume (the density)
 
double total_volume ()
 Check the total volume by adding up the fractional part of the volume in each hypercube.
 
double total_weighted_volume ()
 Check the total volume by adding up the fractional part of the volume in each hypercube.
 
const hypercubefind_hc (const vec_t &x) const
 Return a reference to the hypercube containing the specified point.
 
virtual double pdf (const vec_t &x) const
 The normalized density.
 
virtual double max_weight () const
 Desc.
 
virtual double max_frac_vol () const
 Desc.
 
virtual double max_weighted_vol () const
 Desc.
 
virtual void select_in_largest (vec_t &x) const
 Select a random point in the largest weighted box.
 
virtual void operator() (vec_t &x) const
 Sample the distribution.
 

Member Function Documentation

◆ copy_to_vectors()

template<class vec_t = std::vector<double>, class mat_t = const_matrix_view_table<vec_t>>
void o2scl::prob_dens_mdim_amr< vec_t, mat_t >::copy_to_vectors ( size_t &  nd,
size_t &  dc,
size_t &  ms,
std::vector< double > &  data,
std::vector< size_t > &  insides 
)
inline
Note
This function is used for HDF5 I/O

Definition at line 270 of file prob_dens_mdim_amr.h.

◆ initial_parse_new()

template<class vec_t = std::vector<double>, class mat_t = const_matrix_view_table<vec_t>>
void o2scl::prob_dens_mdim_amr< vec_t, mat_t >::initial_parse_new ( mat_t &  m)
inline

This algorithm is slower, but may result in more balanced meshes, particularly when dim_choice is not equal to random .

Idea for Future:
This method computes distances twice, once here and once in the insert() function. There is likely a faster approach.

Definition at line 800 of file prob_dens_mdim_amr.h.

◆ set()

template<class vec_t = std::vector<double>, class mat_t = const_matrix_view_table<vec_t>>
void o2scl::prob_dens_mdim_amr< vec_t, mat_t >::set ( vec_t &  l,
vec_t &  h 
)
inline
Note
Calling this function automatically clears the mesh and the scales.

This function is called by the constructor.

Definition at line 370 of file prob_dens_mdim_amr.h.

◆ set_from_vectors()

template<class vec_t = std::vector<double>, class mat_t = const_matrix_view_table<vec_t>>
void o2scl::prob_dens_mdim_amr< vec_t, mat_t >::set_from_vectors ( size_t &  nd,
size_t &  dc,
size_t &  ms,
const std::vector< double > &  data,
const std::vector< size_t > &  insides 
)
inline
Note
This function is used for HDF5 I/O

Definition at line 311 of file prob_dens_mdim_amr.h.

◆ two_indices_to_density()

template<class vec_t = std::vector<double>, class mat_t = const_matrix_view_table<vec_t>>
void o2scl::prob_dens_mdim_amr< vec_t, mat_t >::two_indices_to_density ( size_t  i,
size_t  j,
table3d t3d,
std::string  slice 
)
inline

This function presumes that the o2scl::table3d grid has already been created and uses it to create the density. Note that this function will not warn you if the grid refers to points outside the limits of the o2scl::prob_dens_mdim_amr object, instead it will just give zero for those points.

Definition at line 217 of file prob_dens_mdim_amr.h.


The documentation for this class was generated from the following file:

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).