jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
Classes | Typedefs | Functions
jubatus::core::bandit Namespace Reference

Classes

struct  arm_info
 
class  bandit_base
 
class  bandit_factory
 
class  epsilon_greedy
 
struct  epsilon_greedy_config
 
class  exp3
 
struct  exp3_config
 
class  softmax
 
struct  softmax_config
 
class  summation_storage
 
class  ucb1
 
struct  ucb1_config
 

Typedefs

typedef jubatus::util::data::unordered_map< std::string, arm_infoarm_info_map
 

Functions

int select_by_weights (const std::vector< double > &weights, jubatus::util::math::random::mtrand &rand)
 
int select_by_weights (const std::vector< double > &weights, mtrand &rand)
 

Typedef Documentation

typedef jubatus::util::data::unordered_map<std::string, arm_info> jubatus::core::bandit::arm_info_map

Definition at line 36 of file arm_info.hpp.

Function Documentation

int jubatus::core::bandit::select_by_weights ( const std::vector< double > &  weights,
jubatus::util::math::random::mtrand &  rand 
)
int jubatus::core::bandit::select_by_weights ( const std::vector< double > &  weights,
mtrand &  rand 
)

Definition at line 28 of file select_by_weights.cpp.

Referenced by jubatus::core::bandit::softmax::select_arm(), and jubatus::core::bandit::exp3::select_arm().

29  {
30  double total_weight = std::accumulate(weights.begin(), weights.end(), 0.0);
31  double x = rand.next_double(total_weight);
32 
33  double w = 0;
34  for (size_t i = 0; i < weights.size() - 1; ++i) {
35  w += weights[i];
36  if (x < w) {
37  return i;
38  }
39  }
40  return weights.size() - 1;
41 }

Here is the caller graph for this function: