Vowpal Wabbit
Loading...
Searching...
No Matches
Public Member Functions | List of all members
VW::rand_state Class Reference

#include <random.h>

Public Member Functions

 rand_state ()=default
 
 rand_state (uint64_t initial)
 Construct a new rand state object with the given seed. More...
 
constexpr uint64_t get_current_state () const noexcept
 Get the current random state. More...
 
float get_and_update_random ()
 Get the next random value in the range [0,1] and update the PRG state. More...
 
float get_and_update_gaussian ()
 Generate a random number from the gaussian distribution using the Box-Muller transform. More...
 
float get_random () const
 Get the next random value in the range [0,1], but do not update the PRG state. This means that if this is called successively, the same value will be returned. More...
 
void set_random_state (uint64_t new_state) noexcept
 Override the current PRG state value. More...
 

Constructor & Destructor Documentation

◆ rand_state() [1/2]

VW::rand_state::rand_state ( )
default

◆ rand_state() [2/2]

VW::rand_state::rand_state ( uint64_t  initial)
inline

Construct a new rand state object with the given seed.

Parameters
initialinitial seed

Member Function Documentation

◆ get_and_update_gaussian()

float VW::rand_state::get_and_update_gaussian ( )
inline

Generate a random number from the gaussian distribution using the Box-Muller transform.

Returns
float number sampled from gaussian distribution

◆ get_and_update_random()

float VW::rand_state::get_and_update_random ( )
inline

Get the next random value in the range [0,1] and update the PRG state.

Returns
float random number in range [0,1]

◆ get_current_state()

constexpr uint64_t VW::rand_state::get_current_state ( ) const
inlineconstexprnoexcept

Get the current random state.

Returns
uint64_t state value of PRG

◆ get_random()

float VW::rand_state::get_random ( ) const
inline

Get the next random value in the range [0,1], but do not update the PRG state. This means that if this is called successively, the same value will be returned.

Returns
float

◆ set_random_state()

void VW::rand_state::set_random_state ( uint64_t  new_state)
inlinenoexcept

Override the current PRG state value.

Parameters
new_statenew state value

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