NeoPZ
TPZConstrainedNormalRandom.h
Go to the documentation of this file.
1 /*
2  * File: TPZConstrainedNormalRandom.h
3  * Author: quinelato
4  *
5  * Created on 5 de Dezembro de 2017, 15:28
6  */
7 
8 #ifndef TPZCONSTRAINEDNORMALRANDOM_H
9 #define TPZCONSTRAINEDNORMALRANDOM_H
10 
11 #include "TPZConstrainedRandom.h"
12 #include "TPZNormalRandom.h"
13 
14 template <typename TVar>
15 class TPZConstrainedNormalRandom : virtual public TPZConstrainedRandom<TVar>, virtual public TPZNormalRandom<TVar> {
16 public:
17  TPZConstrainedNormalRandom(TVar begin, TVar end, TVar mean, TVar stdev): TPZConstrainedRandom<TVar>(begin, end), TPZNormalRandom<TVar>(mean, stdev) {
18  }
20  }
21  virtual TPZRandom<TVar> *clone(){
22  return new TPZConstrainedNormalRandom<TVar>(*this);
23  }
24  virtual TVar next();
25  TVar pdf(TVar x);
27  }
28 
29 };
30 
31 template <typename TVar>
33  TVar value;
34  do {
36  } while (value <= this->fbegin || value >= this->fend);
37  return value;
38 }
39 
40 template <typename TVar>
42  if (x<this->fbegin || x > this->fend) return 0;
43  TVar normal_pdf = TPZNormalRandom<TVar>::pdf(x);
45  return normal_pdf / area;
46 }
47 
48 #endif /* TPZCONSTRAINEDNORMALRANDOM_H */
49 
virtual TVar next()
TVar pdf(TVar x)
TPZConstrainedNormalRandom(const TPZConstrainedNormalRandom< TVar > &orig)
TPZConstrainedNormalRandom(TVar begin, TVar end, TVar mean, TVar stdev)
TVar cdf(TVar x)
virtual TPZRandom< TVar > * clone()