PeriDEM 0.2.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
util::DistributionSample< T > Class Template Reference

Templated probability distribution. More...

#include <randomDist.h>

Collaboration diagram for util::DistributionSample< T >:

Public Member Functions

 DistributionSample (double arg1, double arg2, int seed=-1)
 Constructor.
 
 DistributionSample ()
 Constructor.
 
void init (double arg1, double arg2, int seed=-1)
 Initialize the distribution.
 
double operator() ()
 Sample from the distribution.
 

Data Fields

int d_seed
 Seed.
 
RandGenerator d_gen
 Random number generator.
 
d_dist
 Templated distribution.
 

Detailed Description

template<class T>
class util::DistributionSample< T >

Templated probability distribution.

Template could be log-normal, normal, or uniform distribution

Definition at line 90 of file randomDist.h.

Constructor & Destructor Documentation

◆ DistributionSample() [1/2]

template<class T >
util::DistributionSample< T >::DistributionSample ( double  arg1,
double  arg2,
int  seed = -1 
)
inline

Constructor.

Parameters
arg1Argument 1 (in case of normal distribution this is mean)
arg2Argument 2 (in case of normal distribution this is std)
seedSeed

Definition at line 99 of file randomDist.h.

100 : d_seed(seed), d_gen(get_rd_gen(seed)), d_dist(arg1, arg2){};
T d_dist
Templated distribution.
Definition randomDist.h:136
RandGenerator d_gen
Random number generator.
Definition randomDist.h:133
RandGenerator get_rd_gen(int seed=-1)
Return random number generator.
Definition randomDist.h:30

◆ DistributionSample() [2/2]

template<class T >
util::DistributionSample< T >::DistributionSample ( )
inline

Constructor.

Definition at line 105 of file randomDist.h.

105: d_seed(-1){};

Member Function Documentation

◆ init()

template<class T >
void util::DistributionSample< T >::init ( double  arg1,
double  arg2,
int  seed = -1 
)
inline

Initialize the distribution.

Parameters
arg1Argument 1 (in case of normal distribution this is mean)
arg2Argument 2 (in case of normal distribution this is std)
seedSeed

Definition at line 114 of file randomDist.h.

114 {
115
116 d_seed = seed;
118 d_dist = T(arg1, arg2);
119 }
float T
final time and time step
std::mt19937 RandGenerator
Definition randomDist.h:16

References util::DistributionSample< T >::d_dist, util::DistributionSample< T >::d_gen, util::DistributionSample< T >::d_seed, and util::get_rd_gen().

Here is the call graph for this function:

◆ operator()()

template<class T >
double util::DistributionSample< T >::operator() ( )
inline

Sample from the distribution.

Returns
Sample Sample from the distribution

Definition at line 125 of file randomDist.h.

125 {
126 return d_dist(d_gen);
127 }

References util::DistributionSample< T >::d_dist, and util::DistributionSample< T >::d_gen.

Field Documentation

◆ d_dist

template<class T >
T util::DistributionSample< T >::d_dist

Templated distribution.

Definition at line 136 of file randomDist.h.

Referenced by util::DistributionSample< T >::init(), and util::DistributionSample< T >::operator()().

◆ d_gen

template<class T >
RandGenerator util::DistributionSample< T >::d_gen

Random number generator.

Definition at line 133 of file randomDist.h.

Referenced by util::DistributionSample< T >::init(), and util::DistributionSample< T >::operator()().

◆ d_seed

template<class T >
int util::DistributionSample< T >::d_seed

Seed.

Definition at line 130 of file randomDist.h.

Referenced by util::DistributionSample< T >::init().


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