Rosetta  2020.37
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes | List of all members
numeric::random::WeightedSampler Class Reference

#include <WeightedSampler.hh>

Public Member Functions

 WeightedSampler ()
 Constructor. More...
 
 WeightedSampler (numeric::Size num_weights)
 Constructor. More...
 
 WeightedSampler (utility::vector1< numeric::Real > const &weights)
 Constructor. More...
 
virtual ~WeightedSampler ()
 Destructor. More...
 
 WeightedSampler (WeightedSampler const &)
 Copy constructor. More...
 
WeightedSampleroperator= (WeightedSampler const &)
 Copy operator. More...
 
utility::vector1
< numeric::Real > const & 
weights () const
 get weights More...
 
void weights (utility::vector1< numeric::Real > const &weights)
 set weights More...
 
void add_weight (numeric::Real weight)
 add a single weight to the end More...
 
void set_weight (numeric::Size weight_num, numeric::Real weight)
 set a single weight More...
 
void clear ()
 clear weights More...
 
numeric::Size size () const
 get number of weights More...
 
void resize (numeric::Size num_weights, numeric::Real default_weight=0)
 resize weights More...
 
numeric::Size random_sample () const
 get a random sample using the default random generator More...
 
numeric::Size random_sample (numeric::random::RandomGenerator &) const
 get a random sample by passing a random generator More...
 
numeric::Size random_sample (numeric::Real randnum) const
 get a random sample by passing a random number from 0 to 1 More...
 
bool update_cumulative_distribution () const
 Update the internal cumulative distribution results Returns false if there's an issue with updating the distribution (e.g. empty or all zero weights) More...
 

Private Attributes

utility::vector1< numeric::Realweights_
 
utility::vector1< numeric::Realcumulative_distribution_
 
bool cumulative_distribution_valid_
 

Constructor & Destructor Documentation

numeric::random::WeightedSampler::WeightedSampler ( )

Constructor.

numeric::random::WeightedSampler::WeightedSampler ( numeric::Size  num_weights)

Constructor.

numeric::random::WeightedSampler::WeightedSampler ( utility::vector1< numeric::Real > const &  weights)

Constructor.

numeric::random::WeightedSampler::~WeightedSampler ( )
virtualdefault

Destructor.

numeric::random::WeightedSampler::WeightedSampler ( WeightedSampler const &  weighted_sampler)

Copy constructor.

Member Function Documentation

void numeric::random::WeightedSampler::add_weight ( numeric::Real  weight)
inline

add a single weight to the end

References cumulative_distribution_valid_, and weights_.

void numeric::random::WeightedSampler::clear ( )
inline
WeightedSampler & numeric::random::WeightedSampler::operator= ( WeightedSampler const &  )
default

Copy operator.

numeric::Size numeric::random::WeightedSampler::random_sample ( ) const

get a random sample using the default random generator

References numeric::random::rg(), and numeric::random::uniform().

Referenced by random_sample().

numeric::Size numeric::random::WeightedSampler::random_sample ( numeric::random::RandomGenerator rg) const

get a random sample by passing a random generator

References random_sample(), and numeric::random::RandomGenerator::uniform().

numeric::Size numeric::random::WeightedSampler::random_sample ( numeric::Real  randnum) const

get a random sample by passing a random number from 0 to 1

References cumulative_distribution_, cumulative_distribution_valid_, and update_cumulative_distribution().

void numeric::random::WeightedSampler::resize ( numeric::Size  num_weights,
numeric::Real  default_weight = 0 
)
inline

resize weights

References weights_.

void numeric::random::WeightedSampler::set_weight ( numeric::Size  weight_num,
numeric::Real  weight 
)
inline
numeric::Size numeric::random::WeightedSampler::size ( ) const
inline

get number of weights

References weights_.

Referenced by numeric::random::operator<<().

bool numeric::random::WeightedSampler::update_cumulative_distribution ( ) const

Update the internal cumulative distribution results Returns false if there's an issue with updating the distribution (e.g. empty or all zero weights)

References cumulative_distribution_, cumulative_distribution_valid_, runtime_assert, basic::options::OptionKeys::sc::weight, and weights_.

Referenced by random_sample().

utility::vector1<numeric::Real> const& numeric::random::WeightedSampler::weights ( ) const
inline

get weights

References weights_.

Referenced by numeric::random::operator<<(), and weights().

void numeric::random::WeightedSampler::weights ( utility::vector1< numeric::Real > const &  weights)
inline

set weights

References cumulative_distribution_valid_, weights(), and weights_.

Member Data Documentation

utility::vector1<numeric::Real> numeric::random::WeightedSampler::cumulative_distribution_
mutableprivate
bool numeric::random::WeightedSampler::cumulative_distribution_valid_
mutableprivate
utility::vector1<numeric::Real> numeric::random::WeightedSampler::weights_
private

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