Hydra  4.0.1
A header-only templated C++ framework to perform data analysis on massively parallel platforms.
Random number generation

Random mumber generation and pdf sampling functionalities. More...

Files

file  Random.inl
 
file  RandomUtils.h
 

Functions

template<typename Engine , hydra::detail::Backend BACKEND, typename Iterable , typename FUNCTOR >
std::enable_if< detail::random::is_matching_iterable< Engine, FUNCTOR, Iterable >::value, void >::type hydra::fill_random (hydra::detail::BackendPolicy< BACKEND > const &policy, Iterable &&iterable, FUNCTOR const &functor, size_t seed, size_t rng_jump)
 Fill a range with numbers distributed according a user defined distribution. More...
 
template<typename Engine , typename Iterable , typename FUNCTOR >
std::enable_if< detail::random::is_matching_iterable< Engine, FUNCTOR, Iterable >::value, void >::type hydra::fill_random (Iterable &&iterable, FUNCTOR const &functor, size_t seed, size_t rng_jump)
 Fill a range with numbers distributed according a user defined distribution. More...
 
template<typename Engine , hydra::detail::Backend BACKEND, typename Iterator , typename FUNCTOR >
std::enable_if< !hydra::detail::has_rng_formula< FUNCTOR >::value, void >::type hydra::fill_random (hydra::detail::BackendPolicy< BACKEND > const &policy, Iterator begin, Iterator end, FUNCTOR const &functor, size_t seed, size_t rng_jump)
 Fall back function if RngFormula is not implemented for the requested functor. More...
 
template<typename Engine , typename Iterator , typename FUNCTOR >
std::enable_if< !hydra::detail::has_rng_formula< FUNCTOR >::value, void >::type hydra::fill_random (Iterator begin, Iterator end, FUNCTOR const &functor, size_t seed, size_t rng_jump)
 Fall back function if RngFormula is not implemented for the requested functor. More...
 
template<typename RNG , typename IterableData , typename IterableWeight , hydra::detail::Backend BACKEND>
std::enable_if< detail::random::is_iterable< IterableData >::value &&detail::random::is_iterable< IterableWeight >::value, Range< decltype(std::declval< IterableData >).begin())> >::type hydra::unweight (hydra::detail::BackendPolicy< BACKEND > const &policy, IterableData &&data, IterableWeight &&weights, double max_pdf=-1.0, size_t rng_seed=0x8ec74d321e6b5a27, size_t rng_jump=0)
 This functions reorder a dataset to produce a unweighted sample according to a weights. More...
 
template<typename RNG = default_random_engine, typename DerivedPolicy , typename IteratorData , typename IteratorWeight >
std::enable_if< detail::random::is_iterator< IteratorData >::value &&detail::random::is_iterator< IteratorWeight >::value, Range< IteratorData > >::type hydra::unweight (hydra::thrust::detail::execution_policy_base< DerivedPolicy > const &policy, IteratorData data_begin, IteratorData data_end, IteratorWeight weights_begin, double max_pdf=-1.0, size_t rng_seed=0x8ec74d321e6b5a27, size_t rng_jump=0)
 This functions reorder a dataset to produce a unweighted sample according to the weights [wbegin, wend]. More...
 
template<typename RNG , typename Functor , typename Iterator , typename DerivedPolicy >
std::enable_if< detail::random::is_callable< Functor >::value &&detail::random::is_iterator< Iterator >::value, Range< Iterator >>::type hydra::unweight (hydra::thrust::detail::execution_policy_base< DerivedPolicy > const &policy, Iterator begin, Iterator end, Functor const &functor, double max_pdf=-1.0, size_t rng_seed=0x8ec74d321e6b5a27, size_t rng_jump=0)
 This functions reorder a dataset to produce an unweighted sample according to. More...
 
template<typename RNG = default_random_engine, typename IteratorData , typename IteratorWeight , hydra::detail::Backend BACKEND>
std::enable_if< detail::random::is_iterator< IteratorData >::value &&detail::random::is_iterator< IteratorWeight >::value, Range< IteratorData > >::type hydra::unweight (detail::BackendPolicy< BACKEND > const &policy, IteratorData data_begin, IteratorData data_end, IteratorWeight weights_begin, double max_pdf=-1.0, size_t rng_seed=0x8ec74d321e6b5a27, size_t rng_jump=0)
 This functions reorder a dataset to produce a unweighted sample according to the weights [wbegin, wend]. More...
 
template<typename RNG , typename Functor , typename Iterator , hydra::detail::Backend BACKEND>
std::enable_if< detail::random::is_callable< Functor >::value &&detail::random::is_iterator< Iterator >::value, Range< Iterator >>::type hydra::unweight (hydra::detail::BackendPolicy< BACKEND > const &policy, Iterator begin, Iterator end, Functor const &functor, double max_pdf=-1.0, size_t rng_seed=0x8ec74d321e6b5a27, size_t rng_jump=0)
 This functions reorder a dataset to produce an unweighted sample according to. More...
 
template<typename RNG = default_random_engine, typename IteratorData , typename IteratorWeight >
std::enable_if< detail::random::is_iterator< IteratorData >::value &&detail::random::is_iterator< IteratorWeight >::value, Range< IteratorData >>::type hydra::unweight (IteratorData data_begin, IteratorData data_end, IteratorData weights_begin, double max_pdf=-1.0, size_t rng_seed=0x8ec74d321e6b5a27, size_t rng_jump=0)
 This functions reorder a dataset to produce a unweighted sample according to the weights [wbegin, wend]. More...
 
template<typename RNG , typename Functor , typename Iterator >
std::enable_if< detail::random::is_callable< Functor >::value &&detail::random::is_iterator< Iterator >::value, Range< Iterator >>::type hydra::unweight (Iterator begin, Iterator end, Functor const &functor, double max_pdf=-1.0, size_t rng_seed=0x8ec74d321e6b5a27, size_t rng_jump=0)
 This functions reorder a dataset to produce an unweighted sample according to. More...
 
template<typename RNG , typename Functor , typename Iterable , hydra::detail::Backend BACKEND>
std::enable_if< detail::random::is_callable< Functor >::value &&detail::random::is_iterable< Iterable >::value, Range< decltype(std::declval< Iterable >).begin())>>::type hydra::unweight (hydra::detail::BackendPolicy< BACKEND > const &policy, Iterable &&iterable, Functor const &functor, double max_pdf=-1.0, size_t rng_seed=0x8ec74d321e6b5a27, size_t rng_jump=0)
 This functions reorder a dataset to produce an unweighted sample according to. More...
 
template<typename RNG = default_random_engine, typename IterableData , typename IterableWeight >
std::enable_if< detail::random::is_iterable< IterableData >::value &&detail::random::is_iterable< IterableWeight >::value, Range< decltype(std::declval< IterableData >).begin())>>::type hydra::unweight (IterableData data, IterableWeight weights, double max_pdf=-1.0, size_t rng_seed=0x8ec74d321e6b5a27, size_t rng_jump=0)
 This functions reorder a dataset to produce an unweighted sample according to a weights. More...
 
template<typename RNG = default_random_engine, typename Functor , typename Iterable >
std::enable_if< detail::random::is_callable< Functor >::value &&detail::random::is_iterable< Iterable >::value,Range< decltype(std::declval< Iterable >).begin())> >::type hydra::unweight (Iterable &&iterable, Functor const &functor, double max_pdf=-1.0, size_t rng_seed=0x8ec74d321e6b5a27, size_t rng_jump=0)
 This functions reorder a dataset to produce an unweighted sample according to. More...
 

Variables

template<typename Engine = hydra::default_random_engine, hydra::detail::Backend BACKEND, typename Iterator , typename FUNCTOR >
std::enable_if< hydra::detail::has_rng_formula< FUNCTOR >::value &&std::is_convertible< decltype(std::declval< RngFormula< FUNCTOR > >).Generate(std::declval< Engine & >), std::declval< FUNCTOR const & >))), typename hydra::thrust::iterator_traits< Iterator >::value_type >::value, void >::type hydra::fill_random (hydra::detail::BackendPolicy< BACKEND > const &policy, Iterator begin, Iterator end, FUNCTOR const &functor, size_t seed=0x254a0afcf7da74a2, size_t rng_jump=0)
 Fill a range with numbers distributed according a user defined distribution using a RNG analytical formula. More...
 

Detailed Description

Random mumber generation and pdf sampling functionalities.

Function Documentation

◆ fill_random() [1/4]

template<typename Engine , hydra::detail::Backend BACKEND, typename Iterable , typename FUNCTOR >
std::enable_if< detail::random::is_matching_iterable< Engine, FUNCTOR, Iterable >::value, void >::type hydra::fill_random ( hydra::detail::BackendPolicy< BACKEND > const &  policy,
Iterable &&  iterable,
FUNCTOR const &  functor,
size_t  seed,
size_t  rng_jump 
)

#include <RandomFill.inl>

Fill a range with numbers distributed according a user defined distribution.

Parameters
policybackend to perform the calculation.
iterablerange storing the generated values
functordistribution to be sampled
policybackend to perform the calculation.
iterablerange storing the generated values
functordistribution to be sampled
max_pdfmaximum pdf value for accept-reject method. If no value is set, the maximum value in the sample is used.
rng_seedseed for the underlying pseudo-random number generator
rng_jumpsequence offset for the underlying pseudo-random number generator

◆ fill_random() [2/4]

template<typename Engine , typename Iterable , typename FUNCTOR >
std::enable_if< detail::random::is_matching_iterable< Engine, FUNCTOR, Iterable >::value, void >::type hydra::fill_random ( Iterable &&  iterable,
FUNCTOR const &  functor,
size_t  seed,
size_t  rng_jump 
)

#include <RandomFill.inl>

Fill a range with numbers distributed according a user defined distribution.

Fall back function if the argument is not an Iterable or if itis not convertible to the Functor return value.

Parameters
iterablerange storing the generated values
functordistribution to be sampled
iterablerange storing the generated values
functordistribution to be sampled
max_pdfmaximum pdf value for accept-reject method. If no value is set, the maximum value in the sample is used.
rng_seedseed for the underlying pseudo-random number generator
rng_jumpsequence offset for the underlying pseudo-random number generator

◆ fill_random() [3/4]

template<typename Engine , hydra::detail::Backend BACKEND, typename Iterator , typename FUNCTOR >
std::enable_if< !hydra::detail::has_rng_formula< FUNCTOR >::value, void >::type hydra::fill_random ( hydra::detail::BackendPolicy< BACKEND > const &  policy,
Iterator  begin,
Iterator  end,
FUNCTOR const &  functor,
size_t  seed = 0x254a0afcf7da74a2,
size_t  rng_jump = 0 
)

#include <RandomFill.inl>

Fall back function if RngFormula is not implemented for the requested functor.

Parameters
policybackend to perform the calculation.
beginbeginning of the range storing the generated values
endending of the range storing the generated values
functordistribution to be sampled
max_pdfmaximum pdf value for accept-reject method. If no value is set, the maximum value in the sample is used.
rng_seedseed for the underlying pseudo-random number generator
rng_jumpsequence offset for the underlying pseudo-random number generator

◆ fill_random() [4/4]

template<typename Engine , typename Iterator , typename FUNCTOR >
std::enable_if< !hydra::detail::has_rng_formula< FUNCTOR >::value, void >::type hydra::fill_random ( Iterator  begin,
Iterator  end,
FUNCTOR const &  functor,
size_t  seed = 0x254a0afcf7da74a2,
size_t  rng_jump = 0 
)

#include <RandomFill.inl>

Fall back function if RngFormula is not implemented for the requested functor.

Parameters
beginbeginning of the range storing the generated values
endending of the range storing the generated values
functordistribution to be sampled
max_pdfmaximum pdf value for accept-reject method. If no value is set, the maximum value in the sample is used.
rng_seedseed for the underlying pseudo-random number generator
rng_jumpsequence offset for the underlying pseudo-random number generator

◆ unweight() [1/10]

template<typename RNG , typename IterableData , typename IterableWeight , hydra::detail::Backend BACKEND>
std::enable_if< detail::random::is_iterable< IterableData >::value &&detail::random::is_iterable< IterableWeight >::value, Range< decltype(std::declval< IterableData >).begin())> >::type hydra::unweight ( hydra::detail::BackendPolicy< BACKEND > const &  policy,
IterableData &&  data,
IterableWeight &&  weights,
double  max_pdf = -1.0,
size_t  rng_seed = 0x8ec74d321e6b5a27,
size_t  rng_jump = 0 
)

#include <Random.inl>

This functions reorder a dataset to produce a unweighted sample according to a weights.

The length of the range

Parameters
weightsshould be equal or greater than the
datasize.
policyparallel backend to perform the unweighting
weightsthe range of weights
datathe range corresponding dataset
max_pdfmaximum pdf value for accept-reject method. If no value is set, the maximum value in the sample is used.
rng_seedseed for the underlying pseudo-random number generator
rng_jumpsequence offset for the underlying pseudo-random number generator
Returns
hydra::Range object pointing unweighted sample.

◆ unweight() [2/10]

template<typename RNG = default_random_engine, typename DerivedPolicy , typename IteratorData , typename IteratorWeight >
std::enable_if<detail::random::is_iterator<IteratorData>::value && detail::random::is_iterator<IteratorWeight>::value,Range<IteratorData> >::type hydra::unweight ( hydra::thrust::detail::execution_policy_base< DerivedPolicy > const &  policy,
IteratorData  data_begin,
IteratorData  data_end,
IteratorWeight  weights_begin,
double  max_pdf = -1.0,
size_t  rng_seed = 0x8ec74d321e6b5a27,
size_t  rng_jump = 0 
)

#include <Random.h>

This functions reorder a dataset to produce a unweighted sample according to the weights [wbegin, wend].

The length of the range [wbegin, wend] should be equal or greater than the dataset size.

Parameters
policyparallel backend to perform the unweighting
data_beginiterator pointing to the begin of the range of weights
data_enditerator pointing to the begin of the range of weights
weights_beginiterator pointing to the begin of the range of data
max_pdfmaximum pdf value for accept-reject method. If no value is set, the maximum value in the sample is used.
rng_seedseed for the underlying pseudo-random number generator
rng_jumpsequence offset for the underlying pseudo-random number generator
Returns
hydra::Range object pointing unweighted sample.

◆ unweight() [3/10]

template<typename RNG , typename Functor , typename Iterator , typename DerivedPolicy >
std::enable_if< detail::random::is_callable<Functor>::value && detail::random::is_iterator<Iterator>::value, Range<Iterator>>::type hydra::unweight ( hydra::thrust::detail::execution_policy_base< DerivedPolicy > const &  policy,
Iterator  begin,
Iterator  end,
Functor const &  functor,
double  max_pdf = -1.0,
size_t  rng_seed = 0x8ec74d321e6b5a27,
size_t  rng_jump = 0 
)

#include <Random.inl>

This functions reorder a dataset to produce an unweighted sample according to.

Parameters
functor.
policy
begin
end
functor
max_pdfmaximum pdf value for accept-reject method. If no value is set, the maximum value in the sample is used.
rng_seedseed for the underlying pseudo-random number generator
rng_jumpsequence offset for the underlying pseudo-random number generator
Returns
hydra::Range object pointing unweighted sample.

◆ unweight() [4/10]

template<typename RNG = default_random_engine, typename IteratorData , typename IteratorWeight , hydra::detail::Backend BACKEND>
std::enable_if<detail::random::is_iterator<IteratorData>::value && detail::random::is_iterator<IteratorWeight>::value,Range<IteratorData> >::type hydra::unweight ( detail::BackendPolicy< BACKEND > const &  policy,
IteratorData  data_begin,
IteratorData  data_end,
IteratorWeight  weights_begin,
double  max_pdf = -1.0,
size_t  rng_seed = 0x8ec74d321e6b5a27,
size_t  rng_jump = 0 
)

#include <Random.h>

This functions reorder a dataset to produce a unweighted sample according to the weights [wbegin, wend].

The length of the range [wbegin, wend] should be equal or greater than the dataset size.

Parameters
policyparallel backend to perform the unweighting
data_beginiterator pointing to the begin of the range of weights
data_enditerator pointing to the begin of the range of weights
weights_beginiterator pointing to the begin of the range of data
max_pdfmaximum pdf value for accept-reject method. If no value is set, the maximum value in the sample is used.
rng_seedseed for the underlying pseudo-random number generator
rng_jumpsequence offset for the underlying pseudo-random number generator
Returns
hydra::Range object pointing unweighted sample.

◆ unweight() [5/10]

template<typename RNG , typename Functor , typename Iterator , hydra::detail::Backend BACKEND>
std::enable_if< detail::random::is_callable<Functor>::value && detail::random::is_iterator<Iterator>::value, Range<Iterator>>::type hydra::unweight ( hydra::detail::BackendPolicy< BACKEND > const &  policy,
Iterator  begin,
Iterator  end,
Functor const &  functor,
double  max_pdf = -1.0,
size_t  rng_seed = 0x8ec74d321e6b5a27,
size_t  rng_jump = 0 
)

#include <Random.inl>

This functions reorder a dataset to produce an unweighted sample according to.

Parameters
functor.
policy
begin
end
functor
max_pdfmaximum pdf value for accept-reject method. If no value is set, the maximum value in the sample is used.
rng_seedseed for the underlying pseudo-random number generator
rng_jumpsequence offset for the underlying pseudo-random number generator
Returns
hydra::Range object pointing unweighted sample.

◆ unweight() [6/10]

template<typename RNG = default_random_engine, typename IteratorData , typename IteratorWeight >
std::enable_if< detail::random::is_iterator<IteratorData>::value && detail::random::is_iterator<IteratorWeight>::value, Range<IteratorData>>::type hydra::unweight ( IteratorData  data_begin,
IteratorData  data_end,
IteratorData  weights_begin,
double  max_pdf = -1.0,
size_t  rng_seed = 0x8ec74d321e6b5a27,
size_t  rng_jump = 0 
)

#include <Random.h>

This functions reorder a dataset to produce a unweighted sample according to the weights [wbegin, wend].

The length of the range [wbegin, wend] should be equal or greater than the dataset size.

Parameters
data_beginiterator pointing to the begin of the range of weights
data_enditerator pointing to the begin of the range of weights
weights_beginiterator pointing to the begin of the range of data
max_pdfmaximum pdf value for accept-reject method. If no value is set, the maximum value in the sample is used.
rng_seedseed for the underlying pseudo-random number generator
rng_jumpsequence offset for the underlying pseudo-random number generator
Returns
hydra::Range object pointing unweighted sample.

◆ unweight() [7/10]

template<typename RNG , typename Functor , typename Iterator >
std::enable_if< detail::random::is_callable<Functor>::value && detail::random::is_iterator<Iterator>::value, Range<Iterator>>::type hydra::unweight ( Iterator  begin,
Iterator  end,
Functor const &  functor,
double  max_pdf = -1.0,
size_t  rng_seed = 0x8ec74d321e6b5a27,
size_t  rng_jump = 0 
)

#include <Random.inl>

This functions reorder a dataset to produce an unweighted sample according to.

Parameters
functor.
begin
end
functor
max_pdfmaximum pdf value for accept-reject method. If no value is set, the maximum value in the sample is used.
rng_seedseed for the underlying pseudo-random number generator
rng_jumpsequence offset for the underlying pseudo-random number generator
Returns
hydra::Range object pointing unweighted sample.

◆ unweight() [8/10]

template<typename RNG , typename Functor , typename Iterable , hydra::detail::Backend BACKEND>
std::enable_if< detail::random::is_callable<Functor>::value && detail::random::is_iterable<Iterable>::value , Range< decltype(std::declval<Iterable>).begin())>>::type hydra::unweight ( hydra::detail::BackendPolicy< BACKEND > const &  policy,
Iterable &&  iterable,
Functor const &  functor,
double  max_pdf = -1.0,
size_t  rng_seed = 0x8ec74d321e6b5a27,
size_t  rng_jump = 0 
)

#include <Random.inl>

This functions reorder a dataset to produce an unweighted sample according to.

Parameters
functor.
iterable
functor
max_pdfmaximum pdf value for accept-reject method. If no value is set, the maximum value in the sample is used.
rng_seedseed for the underlying pseudo-random number generator
rng_jumpsequence offset for the underlying pseudo-random number generator
Returns
hydra::Range object pointing unweighted sample.

◆ unweight() [9/10]

template<typename RNG = default_random_engine, typename IterableData , typename IterableWeight >
std::enable_if< detail::random::is_iterable<IterableData>::value && detail::random::is_iterable<IterableWeight>::value, Range< decltype(std::declval<IterableData>).begin())>>::type hydra::unweight ( IterableData  data,
IterableWeight  weights,
double  max_pdf = -1.0,
size_t  rng_seed = 0x8ec74d321e6b5a27,
size_t  rng_jump = 0 
)

#include <Random.h>

This functions reorder a dataset to produce an unweighted sample according to a weights.

The length of the range

Parameters
weightsshould be equal or greater than the
datasize.
weightsthe range of weights
datathe range corresponding dataset
max_pdfmaximum pdf value for accept-reject method. If no value is set, the maximum value in the sample is used.
rng_seedseed for the underlying pseudo-random number generator
rng_jumpsequence offset for the underlying pseudo-random number generator
Returns
hydra::Range object pointing unweighted sample.

◆ unweight() [10/10]

template<typename RNG = default_random_engine, typename Functor , typename Iterable >
std::enable_if<detail::random::is_callable<Functor>::value && detail::random::is_iterable<Iterable>::value ,Range< decltype(std::declval<Iterable>).begin())> >::type hydra::unweight ( Iterable &&  iterable,
Functor const &  functor,
double  max_pdf = -1.0,
size_t  rng_seed = 0x8ec74d321e6b5a27,
size_t  rng_jump = 0 
)

#include <Random.h>

This functions reorder a dataset to produce an unweighted sample according to.

Parameters
functor.
iterable
functor
max_pdfmaximum pdf value for accept-reject method. If no value is set, the maximum value in the sample is used.
rng_seedseed for the underlying pseudo-random number generator
rng_jumpsequence offset for the underlying pseudo-random number generator
Returns
hydra::Range object pointing unweighted sample.

Variable Documentation

◆ fill_random

template<typename Engine = hydra::default_random_engine, hydra::detail::Backend BACKEND, typename Iterator , typename FUNCTOR >
hydra::fill_random ( hydra::detail::BackendPolicy< BACKEND > const &  policy,
Iterator  begin,
Iterator  end,
FUNCTOR const &  functor,
size_t  seed = 0x254a0afcf7da74a2,
size_t  rng_jump = 0 
)

#include <Random.h>

Initial value:
{
nentries
Definition: basic_fit.inl:102
hydra::detail::BackendPolicy< hydra::detail::Backend::Device >::container< T > vector
Definition: DEVICE.h:70
auto data
Definition: basic_distributions.inl:100

Fill a range with numbers distributed according a user defined distribution using a RNG analytical formula.

Fall back function if RngFormula::Generate() return value is not convertible to functor return value.

Parameters
policybackend to perform the calculation.
beginbeginning of the range storing the generated values
endending of the range storing the generated values
functordistribution to be sampled
max_pdfmaximum pdf value for accept-reject method. If no value is set, the maximum value in the sample is used.
rng_seedseed for the underlying pseudo-random number generator
rng_jumpsequence offset for the underlying pseudo-random number generator
beginbeginning of the range storing the generated values
endending of the range storing the generated values
functordistribution to be sampled
max_pdfmaximum pdf value for accept-reject method. If no value is set, the maximum value in the sample is used.
rng_seedseed for the underlying pseudo-random number generator
rng_jumpsequence offset for the underlying pseudo-random number generator
Examples:
basic_fit_range_semantics.inl, binned_extended_logLL_fit.inl, cufft.inl, extended_logLL_fit.inl, fft.inl, fill_basic_distributions.inl, fractional_logLL_fit.inl, multidimensional_fit.inl, and splot.inl.