1 //                                               -*- C++ -*-
2 /**
3  *  @brief Abstract top-level class for Discrete distributions
4  *
5  *  Copyright 2005-2021 Airbus-EDF-IMACS-ONERA-Phimeca
6  *
7  *  This library is free software: you can redistribute it and/or modify
8  *  it under the terms of the GNU Lesser General Public License as published by
9  *  the Free Software Foundation, either version 3 of the License, or
10  *  (at your option) any later version.
11  *
12  *  This library is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU Lesser General Public License for more details.
16  *
17  *  You should have received a copy of the GNU Lesser General Public License
18  *  along with this library.  If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 #ifndef OPENTURNS_DISCRETEDISTRIBUTION_HXX
22 #define OPENTURNS_DISCRETEDISTRIBUTION_HXX
23 
24 #include "openturns/OTprivate.hxx"
25 #include "openturns/DistributionImplementation.hxx"
26 #include "openturns/ResourceMap.hxx"
27 
28 BEGIN_NAMESPACE_OPENTURNS
29 
30 /**
31  * @class DiscreteDistribution
32  *
33  * A subclass for Discrete usual distributions.
34  */
35 class OT_API DiscreteDistribution
36   : public DistributionImplementation
37 {
38   CLASSNAME
39 public:
40 
41 
42   /** Default constructor */
43   DiscreteDistribution();
44 
45   /** Virtual constructor */
46   DiscreteDistribution * clone() const override;
47 
48   /** Comparison operator */
49   Bool operator ==(const DiscreteDistribution & other) const;
50 
51   /** String converter */
52   String __repr__() const override;
53 
54   /** Get the PDF of the distribution */
55   using DistributionImplementation::computePDF;
56   Scalar computePDF(const Point & point) const override;
57   virtual Scalar computePDF(const Indices & point) const;
58 
59   /* Methods inherited from upper classes */
60 
61   /** Tell if the distribution is continuous */
62   Bool isContinuous() const override;
63 
64   /** Tell if the distribution is discrete */
65   Bool isDiscrete() const override;
66 
67   /** Tell if the distribution is integer valued */
68   Bool isIntegral() const override;
69 
70   /** Support tolerance accessor */
71   void setSupportEpsilon(const Scalar epsilon);
72   Scalar getSupportEpsilon() const;
73 
74   /** Method save() stores the object through the StorageManager */
75   void save(Advocate & adv) const override;
76 
77   /** Method load() reloads the object from the StorageManager */
78   void load(Advocate & adv) override;
79 
80 protected:
81   /** Tolerance to say if a point is in the support of the distribution */
82   Scalar supportEpsilon_;
83 
84 private:
85 
86 }; /* class DiscreteDistribution */
87 
88 
89 END_NAMESPACE_OPENTURNS
90 
91 #endif /* OPENTURNS_DISCRETEDISTRIBUTION_HXX */
92