ATLAS Offline Software
Loading...
Searching...
No Matches
Athena_test::normal_distribution< T > Class Template Reference

#include <random.h>

Collaboration diagram for Athena_test::normal_distribution< T >:

Public Member Functions

 normal_distribution (T mu, T s)
operator() (URNG &rng) const

Private Attributes

m_mu
m_s

Detailed Description

template<class T>
class Athena_test::normal_distribution< T >

Definition at line 101 of file random.h.

Constructor & Destructor Documentation

◆ normal_distribution()

template<class T>
Athena_test::normal_distribution< T >::normal_distribution ( T mu,
T s )
inline

Member Function Documentation

◆ operator()()

template<class T>
T Athena_test::normal_distribution< T >::operator() ( URNG & rng) const

Definition at line 114 of file random.h.

115{
116 // Stamdard Box-Muller transform a la Numerical Recipes, except that for simplicity
117 // i don't try to remember the second generated number between calls. I don't
118 // really care about performance here.
119 T v1, v2, r2;
120 do {
121 v1 = 2*(static_cast<T>(rng()) / URNG::max())-1;
122 v2 = 2*(static_cast<T>(rng()) / URNG::max())-1;
123 r2 = v1*v1 + v2*v2;
124 } while (r2 >= 1);
125
126 T fac = sqrt(-2*log(r2) / r2);
127 return v1*fac*m_s + m_mu;
128}
static constexpr result_type max()
Definition random.h:82

Member Data Documentation

◆ m_mu

template<class T>
T Athena_test::normal_distribution< T >::m_mu
private

Definition at line 108 of file random.h.

◆ m_s

template<class T>
T Athena_test::normal_distribution< T >::m_s
private

Definition at line 109 of file random.h.


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