KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
discrete_random_variable.h
Go to the documentation of this file.
1 //
2 // Authors:
3 // Guillermo Casas gcasas@cimne-upc.edu
4 //
5 
6 #ifndef DISCRETE_RANDOM_VARIABLE_H
7 #define DISCRETE_RANDOM_VARIABLE_H
8 
9 
10 // System includes
11 #include <string>
12 #include <numeric>
13 #include <iostream>
14 #include <random>
15 
16 // Project includes
17 #include "random_variable.h"
18 
19 namespace Kratos {
20 
21 class KRATOS_API(DEM_APPLICATION) DiscreteRandomVariable: public RandomVariable {
22 
23 public:
24 
26 
29  DiscreteRandomVariable(const Parameters rParameters);
30  DiscreteRandomVariable(const Parameters rParameters, const int seed);
31 
32  double Sample() override;
33  double ProbabilityDensity(const double x);
34  double GetMean() override;
35 
37  std::string Info() const override
38  {
39  std::stringstream buffer;
40  buffer << "DiscreteRandomVariable" ;
41  return buffer.str();
42 
43  }
44 
46  void PrintInfo(std::ostream& rOStream) const override
47  {
48  rOStream << "DiscreteRandomVariable";
49  }
50 
52 
53  void PrintData(std::ostream& rOStream) const override
54  {
55 
56  }
57 
58 protected:
59  void Check() override;
60 
61 
62 private:
63 
64  void Normalize();
65 
68 
69  double mRelativeClosenessTolerance = 0.0;
70  std::vector<double> mRelativeFrequencies;
71  std::vector<double> mPossibleValues;
72  std::mt19937 mRandomNumberGenerator;
73  std::discrete_distribution<> mTrapezoidsDiscreteDistribution;
74 
75 }; // Class DiscreteRandomVariable
76 
77 } // namespace Kratos
78 
79 #endif // DISCRETE_RANDOM_VARIABLE_H defined
80 
81 
PeriodicInterfaceProcess & operator=(const PeriodicInterfaceProcess &)=delete
Definition: discrete_random_variable.h:21
std::string Info() const override
Turn back information as a stemplate<class T, std::size_t dim> tring.
Definition: discrete_random_variable.h:37
void PrintInfo(std::ostream &rOStream) const override
Print information about this object.
Definition: discrete_random_variable.h:46
KRATOS_CLASS_POINTER_DEFINITION(DiscreteRandomVariable)
void PrintData(std::ostream &rOStream) const override
Print object's data.
Definition: discrete_random_variable.h:53
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
Definition: random_variable.h:19
int seed
Definition: GenerateWind.py:138
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
def Normalize(v)
Definition: embedded.py:28
x
Definition: sensitivityMatrix.py:49