xrandom

Defined in xtensor/xrandom.hpp

default_engine_type &xt::random::get_default_random_engine()

Returns a reference to the default random number engine.

void xt::random::seed(seed_type seed)

Seeds the default random number generator with seed.

Parameters
  • seed: The seed

template <class T, class S, class E = random::default_engine_type>
auto xt::random::rand(const S &shape, T lower = 0, T upper = 1, E &engine = random::get_default_random_engine())

xexpression with specified shape containing uniformly distributed random numbers in the interval from lower to upper, excluding upper.

Numbers are drawn from std::uniform_real_distribution.

Parameters
  • shape: shape of resulting xexpression
  • lower: lower bound
  • upper: upper bound
  • engine: random number engine
Template Parameters
  • T: number type to use

template <class T, class S, class E = random::default_engine_type>
auto xt::random::randint(const S &shape, T lower = 0, T upper = std::numeric_limits< T >::max(), E &engine = random::get_default_random_engine())

xexpression with specified shape containing uniformly distributed random integers in the interval from lower to upper, excluding upper.

Numbers are drawn from std::uniform_int_distribution.

Parameters
  • shape: shape of resulting xexpression
  • lower: lower bound
  • upper: upper bound
  • engine: random number engine
Template Parameters
  • T: number type to use

template <class T, class S, class E = random::default_engine_type>
auto xt::random::randn(const S &shape, T mean = 0, T std_dev = 1, E &engine = random::get_default_random_engine())

xexpression with specified shape containing numbers sampled from the Normal (Gaussian) random number distribution with mean mean and standard deviation std_dev.

Numbers are drawn from std::normal_distribution.

Parameters
  • shape: shape of resulting xexpression
  • mean: mean of normal distribution
  • std_dev: standard deviation of normal distribution
  • engine: random number engine
Template Parameters
  • T: number type to use