MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
moose::normal_distribution< T > Class Template Reference

#include <NormalDistribution.hpp>

+ Inheritance diagram for moose::normal_distribution< T >:
+ Collaboration diagram for moose::normal_distribution< T >:

Public Member Functions

 normal_distribution (T mean=0.0, T sigma=1.0)
 
double operator() (moose::MOOSE_RNG_DEFAULT_ENGINE &r)
 
 ~normal_distribution ()
 

Public Attributes

mean_
 
sigma_
 

Detailed Description

template<typename T = double>
class moose::normal_distribution< T >

Get a Normally Distribution value from a given RNG.

Template Parameters
T

Definition at line 143 of file NormalDistribution.hpp.

Constructor & Destructor Documentation

template<typename T = double>
moose::normal_distribution< T >::normal_distribution ( mean = 0.0,
sigma = 1.0 
)
inline

Definition at line 148 of file NormalDistribution.hpp.

148  :
149  mean_(mean), sigma_(sigma)
150  {
151  mean_ = mean;
152  sigma_ = sigma;
153  }
template<typename T = double>
moose::normal_distribution< T >::~normal_distribution ( )
inline

Definition at line 155 of file NormalDistribution.hpp.

155 { ; }

Member Function Documentation

template<typename T = double>
double moose::normal_distribution< T >::operator() ( moose::MOOSE_RNG_DEFAULT_ENGINE r)
inline

Definition at line 157 of file NormalDistribution.hpp.

158  {
159  unsigned long U=0, sign=0, i=0, j=0;
160  T x=0, y=0;
161 
162  while (1)
163  {
164  U = r();
165  i = U & 0x0000007F; /* 7 bit to choose the step */
166  sign = U & 0x00000080; /* 1 bit for the sign */
167  j = U>>8; /* 24 bit for the x-value */
168 
169  x = j*details::wtab[i];
170  if (j < details::ktab[i]) break;
171 
172  if (i<127)
173  {
174  double y0 = 0, y1 = 0;
175  y0 = details::ytab[i];
176  y1 = details::ytab[i+1];
177  y = y1+(y0-y1)*r();
178  }
179  else
180  {
181  x = PARAM_R - std::log(1.0 - r()) / PARAM_R;
182  y = exp( - PARAM_R*(x-0.5* PARAM_R)) * r();
183  }
184  if (y < std::exp(-0.5*x*x)) break;
185  }
186  return sign ? sigma_*x : -sigma_*x;
187  }
static const double wtab[128]
static const unsigned long ktab[128]
void log(string msg, serverity_level_ type=debug, bool redirectToConsole=true, bool removeTicks=true)
Log to console (and to a log-file)
#define PARAM_R
static const double ytab[128]

Member Data Documentation

template<typename T = double>
T moose::normal_distribution< T >::mean_

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