Open3D (C++ API)  0.18.0+252c867
Public Member Functions | Protected Attributes
open3d::utility::random::DiscreteGenerator< T > Class Template Reference

#include <Random.h>

Public Member Functions

template<typename InputIt >
 DiscreteGenerator (InputIt first, InputIt last)
 
operator() ()
 Call this to generate a discretely distributed integer value. More...
 

Protected Attributes

std::discrete_distribution< T > distribution_
 

Detailed Description

template<typename T>
class open3d::utility::random::DiscreteGenerator< T >

Generate discretely distributed integer values according to a range of weight values. This class is globally seeded by utility::random::Seed(). This class is a wrapper around std::discrete_distribution.

Example:

// Globally seed Open3D. This will affect all random functions.
// Weighted random choice of size_t
std::vector<double> weights{1, 2, 3, 4, 5};
utility::random::DiscreteGenerator<size_t> gen(weights.cbegin(),
weights.cend()); for (size_t i = 0; i < 10; i++) {
std::cout << gen() << std::endl;
}
void Seed(const int seed)
Set Open3D global random seed.
Definition: Random.cpp:53

Constructor & Destructor Documentation

◆ DiscreteGenerator()

template<typename T >
template<typename InputIt >
open3d::utility::random::DiscreteGenerator< T >::DiscreteGenerator ( InputIt  first,
InputIt  last 
)
inline

Generate discretely distributed integer values according to a range of weight values.

Parameters
firstThe iterator or pointer pointing to the first element in the range of weights.
lastThe iterator or pointer pointing to one past the last element in the range of weights.

Member Function Documentation

◆ operator()()

template<typename T >
T open3d::utility::random::DiscreteGenerator< T >::operator() ( )
inline

Call this to generate a discretely distributed integer value.

Field Documentation

◆ distribution_

template<typename T >
std::discrete_distribution<T> open3d::utility::random::DiscreteGenerator< T >::distribution_
protected

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