Skip to content

Commit

Permalink
Renamed NegativeBinomialFactory into PolyaFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
regislebrun committed Jul 23, 2024
1 parent e86d4e1 commit b0bd086
Show file tree
Hide file tree
Showing 20 changed files with 58 additions and 58 deletions.
10 changes: 5 additions & 5 deletions lib/etc/openturns.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -622,11 +622,11 @@
<Multinomial-eta value_float="1.0e-9" />
<Multinomial-smallA value_float="10.0" />

<!-- OT::NegativeBinomialFactory parameters -->
<NegativeBinomialFactory-AbsolutePrecision value_float="1e-12" />
<NegativeBinomialFactory-RelativePrecision value_float="1e-12" />
<NegativeBinomialFactory-ResidualPrecision value_float="1e-12" />
<NegativeBinomialFactory-MaximumIteration value_int="50" />
<!-- OT::PolyaFactory parameters -->
<PolyaFactory-AbsolutePrecision value_float="1e-12" />
<PolyaFactory-RelativePrecision value_float="1e-12" />
<PolyaFactory-ResidualPrecision value_float="1e-12" />
<PolyaFactory-MaximumIteration value_int="50" />

<!-- OT::Normal parameters -->
<Normal-MaximumCDFEpsilon value_float="5.0e-6" />
Expand Down
10 changes: 5 additions & 5 deletions lib/src/Base/Common/ResourceMap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1251,11 +1251,11 @@ void ResourceMap::loadDefaultConfiguration()
addAsScalar("Multinomial-eta", 1.0e-9);
addAsScalar("Multinomial-smallA", 10.0);

// NegativeBinomialFactory parameters //
addAsScalar("NegativeBinomialFactory-AbsolutePrecision", 1.0e-12);
addAsScalar("NegativeBinomialFactory-RelativePrecision", 1.0e-12);
addAsScalar("NegativeBinomialFactory-ResidualPrecision", 1.0e-12);
addAsUnsignedInteger("NegativeBinomialFactory-MaximumIteration", 50);
// PolyaFactory parameters //
addAsScalar("PolyaFactory-AbsolutePrecision", 1.0e-12);
addAsScalar("PolyaFactory-RelativePrecision", 1.0e-12);
addAsScalar("PolyaFactory-ResidualPrecision", 1.0e-12);
addAsUnsignedInteger("PolyaFactory-MaximumIteration", 50);

// Normal parameters //
addAsScalar("Normal-MaximumCDFEpsilon", 5.0e-6);
Expand Down
4 changes: 2 additions & 2 deletions lib/src/Uncertainty/Distribution/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ ot_add_source_file (Mixture.cxx)
ot_add_source_file (Multinomial.cxx)
ot_add_source_file (MultinomialFactory.cxx)
ot_add_source_file (Polya.cxx)
ot_add_source_file (NegativeBinomialFactory.cxx)
ot_add_source_file (PolyaFactory.cxx)
ot_add_source_file (NonCentralChiSquare.cxx)
ot_add_source_file (NonCentralStudent.cxx)
ot_add_source_file (Normal2DCDF.cxx)
Expand Down Expand Up @@ -294,7 +294,7 @@ ot_install_header_file (Mixture.hxx)
ot_install_header_file (MultinomialFactory.hxx)
ot_install_header_file (Multinomial.hxx)
ot_install_header_file (Polya.hxx)
ot_install_header_file (NegativeBinomialFactory.hxx)
ot_install_header_file (PolyaFactory.hxx)
ot_install_header_file (NonCentralChiSquare.hxx)
ot_install_header_file (NonCentralStudent.hxx)
ot_install_header_file (Normal2DCDF.hxx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "openturns/NegativeBinomialFactory.hxx"
#include "openturns/PolyaFactory.hxx"
#include "openturns/SpecFunc.hxx"
#include "openturns/MethodBoundEvaluation.hxx"
#include "openturns/Brent.hxx"
Expand All @@ -27,21 +27,21 @@

BEGIN_NAMESPACE_OPENTURNS

CLASSNAMEINIT(NegativeBinomialFactory)
CLASSNAMEINIT(PolyaFactory)

static const Factory<NegativeBinomialFactory> Factory_NegativeBinomialFactory;
static const Factory<PolyaFactory> Factory_PolyaFactory;

/* Default constructor */
NegativeBinomialFactory::NegativeBinomialFactory()
PolyaFactory::PolyaFactory()
: DistributionFactoryImplementation()
{
// Nothing to do
}

/* Virtual constructor */
NegativeBinomialFactory * NegativeBinomialFactory::clone() const
PolyaFactory * PolyaFactory::clone() const
{
return new NegativeBinomialFactory(*this);
return new PolyaFactory(*this);
}


Expand Down Expand Up @@ -76,22 +76,22 @@ struct NegativeBinomialFactoryParameterConstraint
Scalar mean_;
};

Distribution NegativeBinomialFactory::build(const Sample & sample) const
Distribution PolyaFactory::build(const Sample & sample) const
{
return buildAsNegativeBinomial(sample).clone();
}

Distribution NegativeBinomialFactory::build(const Point & parameters) const
Distribution PolyaFactory::build(const Point & parameters) const
{
return buildAsNegativeBinomial(parameters).clone();
}

Distribution NegativeBinomialFactory::build() const
Distribution PolyaFactory::build() const
{
return buildAsNegativeBinomial().clone();
}

Polya NegativeBinomialFactory::buildAsNegativeBinomial(const Sample & sample) const
Polya PolyaFactory::buildAsNegativeBinomial(const Sample & sample) const
{
const UnsignedInteger size = sample.getSize();
if (size < 2) throw InvalidArgumentException(HERE) << "Error: cannot build a Polya distribution from a sample of size < 2";
Expand Down Expand Up @@ -134,7 +134,7 @@ Polya NegativeBinomialFactory::buildAsNegativeBinomial(const Sample & sample) co
fB = f(Point(1, b))[0];
}
// Solve the constraint equation
Brent solver(ResourceMap::GetAsScalar("NegativeBinomialFactory-AbsolutePrecision"), ResourceMap::GetAsScalar("NegativeBinomialFactory-RelativePrecision"), ResourceMap::GetAsScalar("NegativeBinomialFactory-ResidualPrecision"), ResourceMap::GetAsUnsignedInteger("NegativeBinomialFactory-MaximumIteration"));
Brent solver(ResourceMap::GetAsScalar("PolyaFactory-AbsolutePrecision"), ResourceMap::GetAsScalar("PolyaFactory-RelativePrecision"), ResourceMap::GetAsScalar("PolyaFactory-ResidualPrecision"), ResourceMap::GetAsUnsignedInteger("PolyaFactory-MaximumIteration"));
// R estimate
const Scalar r = solver.solve(f, 0.0, a, b, fA, fB);
// Corresponding p estimate
Expand All @@ -144,7 +144,7 @@ Polya NegativeBinomialFactory::buildAsNegativeBinomial(const Sample & sample) co
return result;
}

Polya NegativeBinomialFactory::buildAsNegativeBinomial(const Point & parameters) const
Polya PolyaFactory::buildAsNegativeBinomial(const Point & parameters) const
{
try
{
Expand All @@ -158,7 +158,7 @@ Polya NegativeBinomialFactory::buildAsNegativeBinomial(const Point & parameters)
}
}

Polya NegativeBinomialFactory::buildAsNegativeBinomial() const
Polya PolyaFactory::buildAsNegativeBinomial() const
{
return Polya();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
#include "openturns/Multinomial.hxx"
#include "openturns/MultinomialFactory.hxx"
#include "openturns/Polya.hxx"
#include "openturns/NegativeBinomialFactory.hxx"
#include "openturns/PolyaFactory.hxx"
#include "openturns/NonCentralChiSquare.hxx"
#include "openturns/NonCentralStudent.hxx"
#include "openturns/Normal2DCDF.hxx"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef OPENTURNS_NEGATIVEBINOMIALFACTORY_HXX
#define OPENTURNS_NEGATIVEBINOMIALFACTORY_HXX
#ifndef OPENTURNS_POLYAFACTORY_HXX
#define OPENTURNS_POLYAFACTORY_HXX

#include "openturns/OTprivate.hxx"
#include "openturns/DistributionFactoryImplementation.hxx"
Expand All @@ -28,19 +28,19 @@
BEGIN_NAMESPACE_OPENTURNS

/**
* @class NegativeBinomialFactory
* @class PolyaFactory
*/
class OT_API NegativeBinomialFactory
class OT_API PolyaFactory
: public DistributionFactoryImplementation
{
CLASSNAME
public:

/** Default constructor */
NegativeBinomialFactory();
PolyaFactory();

/** Virtual constructor */
NegativeBinomialFactory * clone() const override;
PolyaFactory * clone() const override;

/* Here is the interface that all derived class must implement */
using DistributionFactoryImplementation::build;
Expand All @@ -52,9 +52,9 @@ public:
Polya buildAsNegativeBinomial(const Point & parameters) const;
Polya buildAsNegativeBinomial() const;

}; /* class NegativeBinomialFactory */
}; /* class PolyaFactory */


END_NAMESPACE_OPENTURNS

#endif /* OPENTURNS_NEGATIVEBINOMIALFACTORY_HXX */
#endif /* OPENTURNS_POLYAFACTORY_HXX */
4 changes: 2 additions & 2 deletions lib/src/Uncertainty/Model/DistributionFactory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#include "openturns/LogUniformFactory.hxx"
#include "openturns/MeixnerDistributionFactory.hxx"
#include "openturns/MultinomialFactory.hxx"
#include "openturns/NegativeBinomialFactory.hxx"
#include "openturns/PolyaFactory.hxx"
#include "openturns/NormalCopulaFactory.hxx"
#include "openturns/NormalFactory.hxx"
#include "openturns/ParetoFactory.hxx"
Expand Down Expand Up @@ -141,7 +141,7 @@ DistributionFactory::DistributionFactoryCollection DistributionFactory::GetDiscr
collection.add(DiracFactory());
collection.add(GeometricFactory());
collection.add(MultinomialFactory());
collection.add(NegativeBinomialFactory());
collection.add(PolyaFactory());
collection.add(PoissonFactory());
collection.add(UserDefinedFactory());
collection.add(SkellamFactory());
Expand Down
2 changes: 1 addition & 1 deletion lib/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ ot_check_test (Mixture_std)
ot_check_test (Multinomial_std)
ot_check_test (MultinomialFactory_std)
ot_check_test (Polya_std)
ot_check_test (NegativeBinomialFactory_std)
ot_check_test (PolyaFactory_std)
ot_check_test (NonCentralChiSquare_std)
if (Boost_FOUND)
ot_check_test (NonCentralStudent_std)
Expand Down
4 changes: 2 additions & 2 deletions lib/test/t_DistributionFactory_std.expout
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Continuous univariate factories=[ArcsineFactory,BetaFactory,BurrFactory,ChiFactory,ChiSquareFactory,DirichletFactory,ExponentialFactory,FisherSnedecorFactory,FrechetFactory,GammaFactory,GeneralizedParetoFactory,GumbelFactory,HistogramFactory,InverseNormalFactory,LaplaceFactory,LogisticFactory,LogNormalFactory,LogUniformFactory,MeixnerDistributionFactory,NormalFactory,ParetoFactory,RayleighFactory,RiceFactory,SmoothedUniformFactory,StudentFactory,TrapezoidalFactory,TriangularFactory,TruncatedNormalFactory,UniformFactory,VonMisesFactory,WeibullMaxFactory,WeibullMinFactory]#32
Continuous multivariate factories=[AliMikhailHaqCopulaFactory,BernsteinCopulaFactory,ClaytonCopulaFactory,DirichletFactory,FarlieGumbelMorgensternCopulaFactory,FrankCopulaFactory,GumbelCopulaFactory,NormalCopulaFactory,NormalFactory,PlackettCopulaFactory,StudentFactory]#11
Discrete univariate factories=[BernoulliFactory,BinomialFactory,DiracFactory,GeometricFactory,MultinomialFactory,NegativeBinomialFactory,PoissonFactory,UserDefinedFactory,SkellamFactory]
Discrete univariate factories=[BernoulliFactory,BinomialFactory,DiracFactory,GeometricFactory,MultinomialFactory,PolyaFactory,PoissonFactory,UserDefinedFactory,SkellamFactory]
Discrete multivariate factories=[DiracFactory,MultinomialFactory,UserDefinedFactory]
Univariate factories=[ArcsineFactory,BetaFactory,BurrFactory,ChiFactory,ChiSquareFactory,DirichletFactory,ExponentialFactory,FisherSnedecorFactory,FrechetFactory,GammaFactory,GeneralizedParetoFactory,GumbelFactory,HistogramFactory,InverseNormalFactory,LaplaceFactory,LogisticFactory,LogNormalFactory,LogUniformFactory,MeixnerDistributionFactory,NormalFactory,ParetoFactory,RayleighFactory,RiceFactory,SmoothedUniformFactory,StudentFactory,TrapezoidalFactory,TriangularFactory,TruncatedNormalFactory,UniformFactory,VonMisesFactory,WeibullMaxFactory,WeibullMinFactory,BernoulliFactory,BinomialFactory,DiracFactory,GeometricFactory,MultinomialFactory,NegativeBinomialFactory,PoissonFactory,UserDefinedFactory,SkellamFactory]#41
Univariate factories=[ArcsineFactory,BetaFactory,BurrFactory,ChiFactory,ChiSquareFactory,DirichletFactory,ExponentialFactory,FisherSnedecorFactory,FrechetFactory,GammaFactory,GeneralizedParetoFactory,GumbelFactory,HistogramFactory,InverseNormalFactory,LaplaceFactory,LogisticFactory,LogNormalFactory,LogUniformFactory,MeixnerDistributionFactory,NormalFactory,ParetoFactory,RayleighFactory,RiceFactory,SmoothedUniformFactory,StudentFactory,TrapezoidalFactory,TriangularFactory,TruncatedNormalFactory,UniformFactory,VonMisesFactory,WeibullMaxFactory,WeibullMinFactory,BernoulliFactory,BinomialFactory,DiracFactory,GeometricFactory,MultinomialFactory,PolyaFactory,PoissonFactory,UserDefinedFactory,SkellamFactory]#41
Multivariate factories=[AliMikhailHaqCopulaFactory,BernsteinCopulaFactory,ClaytonCopulaFactory,DirichletFactory,FarlieGumbelMorgensternCopulaFactory,FrankCopulaFactory,GumbelCopulaFactory,NormalCopulaFactory,NormalFactory,PlackettCopulaFactory,StudentFactory,DiracFactory,MultinomialFactory,UserDefinedFactory]#14
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int main(int, char *[])
Polya distribution(15, 0.7);
UnsignedInteger size = 10000;
Sample sample(distribution.getSample(size));
NegativeBinomialFactory factory;
PolyaFactory factory;
Distribution estimatedDistribution(factory.build(sample));
fullprint << "Distribution =" << distribution << std::endl;
fullprint << "Estimated distribution=" << estimatedDistribution << std::endl;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion python/doc/user_manual/statistics_on_sample.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Building distributions from samples
:template: DistributionFactory.rst_t

MultinomialFactory
NegativeBinomialFactory
PolyaFactory
NormalFactory
ParetoFactory
PoissonFactory
Expand Down
2 changes: 1 addition & 1 deletion python/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ ot_add_python_module(dist_bundle2 dist_bundle2_module.i
Multinomial.i Multinomial_doc.i.in
MultinomialFactory.i MultinomialFactory_doc.i.in
Polya.i Polya_doc.i.in
NegativeBinomialFactory.i NegativeBinomialFactory_doc.i.in
PolyaFactory.i PolyaFactory_doc.i.in
NonCentralChiSquare.i NonCentralChiSquare_doc.i.in
NonCentralStudent.i NonCentralStudent_doc.i.in
Normal.i Normal_doc.i.in
Expand Down
11 changes: 0 additions & 11 deletions python/src/NegativeBinomialFactory.i

This file was deleted.

11 changes: 11 additions & 0 deletions python/src/PolyaFactory.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SWIG file PolyaFactory.i

%{
#include "openturns/PolyaFactory.hxx"
%}

%include PolyaFactory_doc.i

%copyctor OT::PolyaFactory;

%include openturns/PolyaFactory.hxx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%feature("docstring") OT::NegativeBinomialFactory
%feature("docstring") OT::PolyaFactory
"Negative Binomial factory.

Notes
Expand All @@ -22,7 +22,7 @@ DistributionFactory, Polya"

// ---------------------------------------------------------------------

%feature("docstring") OT::NegativeBinomialFactory::buildAsNegativeBinomial
%feature("docstring") OT::PolyaFactory::buildAsNegativeBinomial
"Estimate the distribution as native distribution.

**Available usages**:
Expand Down
2 changes: 1 addition & 1 deletion python/src/dist_bundle2_module.i
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
%include Multinomial.i
%include MultinomialFactory.i
%include Polya.i
%include NegativeBinomialFactory.i
%include PolyaFactory.i
%include NonCentralChiSquare.i
%include NonCentralStudent.i
%include Normal.i
Expand Down
2 changes: 1 addition & 1 deletion python/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ ot_pyinstallcheck_test (Mixture_std)
ot_pyinstallcheck_test (Multinomial_std)
ot_pyinstallcheck_test (MultinomialFactory_std)
ot_pyinstallcheck_test (Polya_std)
ot_pyinstallcheck_test (NegativeBinomialFactory_std)
ot_pyinstallcheck_test (PolyaFactory_std)
ot_pyinstallcheck_test (NonCentralChiSquare_std)
if (Boost_FOUND)
ot_pyinstallcheck_test (NonCentralStudent_std)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
distribution = ot.Polya(15, 0.7)
size = 10000
sample = distribution.getSample(size)
factory = ot.NegativeBinomialFactory()
factory = ot.PolyaFactory()
estimatedDistribution = factory.build(sample)
print("distribution=", repr(distribution))
print("Estimated distribution=", repr(estimatedDistribution))
Expand Down

0 comments on commit b0bd086

Please sign in to comment.