CORSIKA  @c8_version@
The framework to simulate particle cascades for astroparticle physics
ExponentialDistribution.hpp
1 /*
2  * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
3  *
4  * This software is distributed under the terms of the GNU General Public
5  * Licence version 3 (GPL Version 3). See file LICENSE for a full version of
6  * the license.
7  */
8 
9 #pragma once
10 
12 #include <random>
13 
14 namespace corsika {
15 
23  template <typename Quantity>
25  static_assert(is_quantity_v<Quantity>, "usable only with Quantity types");
26 
27  typedef typename Quantity::value_type real_type;
28  typedef std::exponential_distribution<real_type> distribution_type;
29 
30  public:
31  typedef Quantity value_type;
32 
33  ExponentialDistribution() = delete;
34 
35  ExponentialDistribution(value_type beta)
36  : beta_(beta) {}
37 
39  : beta_(other.getBeta()) {}
40 
43  if (this == &other) return *this;
44  beta_ = other.getBeta();
45  return *this;
46  }
47 
54  value_type getBeta() const { return beta_; }
55 
62  void setBeta(value_type const& beta) { beta_ = beta; }
63 
72  template <class Generator>
73  value_type operator()(Generator& g) {
74  return beta_ * dist_(g);
75  }
76 
77  private:
78  distribution_type dist_{1.};
79  value_type beta_;
80  };
81 
82 } // namespace corsika
Import and extend the phys::units package.
Describes a random distribution with for a physical quantity of type Quantity.
`, since they are used everywhere as integral part of the framework.
void setBeta(value_type const &beta)
Set parameter of exponential distribution .
value_type operator()(Generator &g)
Generate a random number distributed like .
value_type getBeta() const
Get parameter of exponential distribution .