OPTK  0.1.2
Toolkit for global optimisation algorithms
Public Member Functions | Public Attributes | Protected Attributes | List of all members
sspace::uniform Class Reference

#include <types.hpp>

Inheritance diagram for sspace::uniform:
sspace::param_t sspace::loguniform sspace::quniform sspace::qloguniform

Public Member Functions

 uniform (std::string n, double lower, double upper)
 
 uniform (std::string n, double lower, double upper, pt type)
 
virtual double sample ()
 
- Public Member Functions inherited from sspace::param_t
 param_t (std::string n, pt t)
 
virtual ~param_t ()
 
virtual pt get_type ()
 
virtual std::string get_name ()
 

Public Attributes

double m_lower
 
double m_upper
 

Protected Attributes

std::random_device rd
 
std::mt19937 generator
 
std::uniform_real_distribution< double > dist
 

Detailed Description

A uniform parameter is real-valued and sampled uniformly at random between the lower and upper bound (inclusive).

Constructor & Destructor Documentation

◆ uniform() [1/2]

sspace::uniform::uniform ( std::string  n,
double  lower,
double  upper 
)

The constructor to be used when instantiating a uniform parameter manually.

Parameters
nthe name of this parameter
lowerthe lower bound; as a double
upperthe upper bound; as a double

◆ uniform() [2/2]

sspace::uniform::uniform ( std::string  n,
double  lower,
double  upper,
pt  type 
)

This constructor is used by classes inheriting from uniform, and uses run-time polymorphism to set the desired type (per the inheriting class).

It should (probably) never be called directly.

Member Function Documentation

◆ sample()

double sspace::uniform::sample ( )
virtual

Produces a double-precision value drawn uniformly at random from the given range.

This is a virtual method to allow for runtime polymorphism when using derived classes in the choice parameter type.

Returns
a new random sample

Reimplemented in sspace::qloguniform, sspace::loguniform, and sspace::quniform.

Member Data Documentation

◆ m_lower

double sspace::uniform::m_lower

Lower and upper bounds on the uniform distribution.


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