Rosetta
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

◆ WeightedSampler() [1/4]

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

Constructor.

◆ WeightedSampler() [2/4]

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

Constructor.

◆ WeightedSampler() [3/4]

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

Constructor.

◆ ~WeightedSampler()

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

Destructor.

◆ WeightedSampler() [4/4]

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

Copy constructor.

Member Function Documentation

◆ add_weight()

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

add a single weight to the end

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

◆ clear()

void numeric::random::WeightedSampler::clear ( )
inline

◆ operator=()

WeightedSampler & numeric::random::WeightedSampler::operator= ( WeightedSampler const &  )
default

Copy operator.

◆ random_sample() [1/3]

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().

◆ random_sample() [2/3]

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

get a random sample by passing a random generator

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

◆ random_sample() [3/3]

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_, create_a3b_hbs::i, and update_cumulative_distribution().

◆ resize()

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

resize weights

References weights_.

Referenced by PyMOL-Rosetta-relay-client.SecretInputDialog::__init__().

◆ set_weight()

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

◆ size()

numeric::Size numeric::random::WeightedSampler::size ( ) const
inline

get number of weights

References weights_.

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

◆ update_cumulative_distribution()

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_, create_a3b_hbs::i, runtime_assert, basic::options::OptionKeys::sc::weight, and weights_.

Referenced by random_sample().

◆ weights() [1/2]

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

◆ weights() [2/2]

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

Member Data Documentation

◆ cumulative_distribution_

utility::vector1<numeric::Real> numeric::random::WeightedSampler::cumulative_distribution_
mutableprivate

◆ cumulative_distribution_valid_

bool numeric::random::WeightedSampler::cumulative_distribution_valid_
mutableprivate

◆ weights_

utility::vector1<numeric::Real> numeric::random::WeightedSampler::weights_
private

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