Honeycomb  0.1
Component-Model Framework
Classes | Public Member Functions | Static Public Member Functions | List of all members
honey::Random_< Real > Class Template Reference

Random-related methods. More...

#include <Random.h>

Classes

struct  DistStats
 

Public Member Functions

 Random_ ()
 
 Random_ (RandomGen &gen)
 Construct with random generator to use for all methods. More...
 
void setGen (RandomGen &gen)
 Set random generator to use for all methods. More...
 
RandomGengetGen () const
 Get random generator. More...
 
bool boolean () const
 Generate random bool true/false. More...
 
template<class T >
void sample (const vector< T > &list, szt count, vector< T > &sample) const
 Randomly choose count items from the list with replacement, so an item can be sampled more than once. Result is stored in sample. More...
 
template<class T >
void choose (const vector< T > &list, szt count, vector< T > &chosen, vector< szt > &unchosen) const
 Randomly choose count items from a list without replacement, so an item can't be chosen more than once. Results stored in chosen, and unchosen (unchosen indices). More...
 
template<class T >
void shuffle (vector< T > &list) const
 Randomly permute a list. The entire list will be shuffled into a random order. All permutations have equal probability. More...
 
Vec3 dir () const
 Generate a random unit direction. More...
 
Vec3 dir (const Vec3 &dir, Real dirVarMin, Real dirVarMax) const
 Generate a random unit direction parallel to dir with an angular spread of dirVarMin to dirVarMax (radians) More...
 
Vec2 dir2d () const
 Generate a 2D random unit direction. More...
 

Static Public Member Functions

template<class Range >
static tuple< Real, Real, Realmean (const Range &samples)
 Estimate the sample mean, returns a tuple of (mean, min, max) More...
 
template<class Range >
static Real variance (const Range &samples, Real mean)
 Estimate the sample variance given the mean. This is the unbiased estimator (mean over all possible samples is the population variance) More...
 
static Real stdDev (Real variance)
 Calculate the standard deviation given the variance. More...
 
static Real stdErr (Real sampleSize, Real stddev)
 Calculate the standard error of the mean. This is how well the sample mean appoximates the population mean. The larger the sample, the smaller the error. More...
 
template<class Range >
static DistStats stats (const Range &samples)
 Calculate distribution statistics. More...
 

Detailed Description

template<class Real>
class honey::Random_< Real >

Random-related methods.

Constructor & Destructor Documentation

template<class Real>
honey::Random_< Real >::Random_ ( )
inline
template<class Real>
honey::Random_< Real >::Random_ ( RandomGen gen)
inline

Construct with random generator to use for all methods.

Member Function Documentation

template<class Real>
bool honey::Random_< Real >::boolean ( ) const
inline

Generate random bool true/false.

template<class Real>
template<class T >
void honey::Random_< Real >::choose ( const vector< T > &  list,
szt  count,
vector< T > &  chosen,
vector< szt > &  unchosen 
) const
inline

Randomly choose count items from a list without replacement, so an item can't be chosen more than once. Results stored in chosen, and unchosen (unchosen indices).

template<class Real >
Random_< Real >::Vec3 honey::Random_< Real >::dir ( ) const

Generate a random unit direction.

template<class Real>
Random_< Real >::Vec3 honey::Random_< Real >::dir ( const Vec3 dir,
Real  dirVarMin,
Real  dirVarMax 
) const

Generate a random unit direction parallel to dir with an angular spread of dirVarMin to dirVarMax (radians)

template<class Real >
Random_< Real >::Vec2 honey::Random_< Real >::dir2d ( ) const

Generate a 2D random unit direction.

template<class Real>
RandomGen& honey::Random_< Real >::getGen ( ) const
inline

Get random generator.

template<class Real>
template<class Range >
static tuple<Real,Real,Real> honey::Random_< Real >::mean ( const Range &  samples)
inlinestatic

Estimate the sample mean, returns a tuple of (mean, min, max)

template<class Real>
template<class T >
void honey::Random_< Real >::sample ( const vector< T > &  list,
szt  count,
vector< T > &  sample 
) const
inline

Randomly choose count items from the list with replacement, so an item can be sampled more than once. Result is stored in sample.

template<class Real>
void honey::Random_< Real >::setGen ( RandomGen gen)
inline

Set random generator to use for all methods.

template<class Real>
template<class T >
void honey::Random_< Real >::shuffle ( vector< T > &  list) const
inline

Randomly permute a list. The entire list will be shuffled into a random order. All permutations have equal probability.

template<class Real>
template<class Range >
static DistStats honey::Random_< Real >::stats ( const Range &  samples)
inlinestatic

Calculate distribution statistics.

template<class Real>
static Real honey::Random_< Real >::stdDev ( Real  variance)
inlinestatic

Calculate the standard deviation given the variance.

template<class Real>
static Real honey::Random_< Real >::stdErr ( Real  sampleSize,
Real  stddev 
)
inlinestatic

Calculate the standard error of the mean. This is how well the sample mean appoximates the population mean. The larger the sample, the smaller the error.

template<class Real>
template<class Range >
static Real honey::Random_< Real >::variance ( const Range &  samples,
Real  mean 
)
inlinestatic

Estimate the sample variance given the mean. This is the unbiased estimator (mean over all possible samples is the population variance)


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