diff --git a/ChangeLog b/ChangeLog index 2b1ad91674..a33bea2594 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,7 @@ * Removed deprecated OptimizationResult.getEvaluationNumber * Deprecated BayesDistribution in favor of JointByConditioningDistribution * Deprecated ConditionalDistribution in favor of DeconditionedDistribution + * Deprecated NegativeBinomial in favor of Polya === Documentation === diff --git a/lib/src/Uncertainty/Algorithm/OrthogonalBasis/MeixnerFactory.cxx b/lib/src/Uncertainty/Algorithm/OrthogonalBasis/MeixnerFactory.cxx index 37d53400b2..3af3daa45d 100644 --- a/lib/src/Uncertainty/Algorithm/OrthogonalBasis/MeixnerFactory.cxx +++ b/lib/src/Uncertainty/Algorithm/OrthogonalBasis/MeixnerFactory.cxx @@ -20,7 +20,7 @@ */ #include "openturns/MeixnerFactory.hxx" #include "openturns/PersistentObjectFactory.hxx" -#include "openturns/NegativeBinomial.hxx" +#include "openturns/Polya.hxx" #include "openturns/Exception.hxx" BEGIN_NAMESPACE_OPENTURNS @@ -35,7 +35,7 @@ static const Factory Factory_MeixnerFactory; /* Default constructor, associated with the default Negative Binomial distribution of parameter 1, 1/2. */ MeixnerFactory::MeixnerFactory() - : OrthogonalUniVariatePolynomialFactory(NegativeBinomial()), + : OrthogonalUniVariatePolynomialFactory(Polya()), r_(1.0), p_(0.5) { @@ -43,10 +43,10 @@ MeixnerFactory::MeixnerFactory() } -/* Parameter constructor: lambda is the order of the generalized Meixner polynomial, associated with the NegativeBinomial(r, p) distribution */ +/* Parameter constructor: lambda is the order of the generalized Meixner polynomial, associated with the Polya(r, p) distribution */ MeixnerFactory::MeixnerFactory(const Scalar r, const Scalar p) - : OrthogonalUniVariatePolynomialFactory( NegativeBinomial(r, p) ), + : OrthogonalUniVariatePolynomialFactory( Polya(r, p) ), r_(r), p_(p) { diff --git a/lib/src/Uncertainty/Algorithm/OrthogonalBasis/StandardDistributionPolynomialFactory.cxx b/lib/src/Uncertainty/Algorithm/OrthogonalBasis/StandardDistributionPolynomialFactory.cxx index c0f95bbaa2..4d3ec9482d 100644 --- a/lib/src/Uncertainty/Algorithm/OrthogonalBasis/StandardDistributionPolynomialFactory.cxx +++ b/lib/src/Uncertainty/Algorithm/OrthogonalBasis/StandardDistributionPolynomialFactory.cxx @@ -127,7 +127,7 @@ void StandardDistributionPolynomialFactory::checkSpecificFamily() hasSpecificFamily_ = true; return; } - if (measureType == "NegativeBinomial") + if (measureType == "Polya") { specificFamily_ = MeixnerFactory(parameter[0], parameter[1]); LOGDEBUG(OSS() << "measureType=" << measureType << ", specificFamily=" << specificFamily_); diff --git a/lib/src/Uncertainty/Algorithm/OrthogonalBasis/openturns/MeixnerFactory.hxx b/lib/src/Uncertainty/Algorithm/OrthogonalBasis/openturns/MeixnerFactory.hxx index 57e8ad22bd..92dea03ea6 100644 --- a/lib/src/Uncertainty/Algorithm/OrthogonalBasis/openturns/MeixnerFactory.hxx +++ b/lib/src/Uncertainty/Algorithm/OrthogonalBasis/openturns/MeixnerFactory.hxx @@ -43,7 +43,7 @@ public: /** Default constructor, associated with the default Negative Binomial distribution of parameter 1, 1/2. */ MeixnerFactory(); - /** Parameter constructor: lambda is the order of the generalized Meixner polynomial, associated with the NegativeBinomial(r, p) distribution */ + /** Parameter constructor: lambda is the order of the generalized Meixner polynomial, associated with the Polya(r, p) distribution */ MeixnerFactory(const Scalar r, const Scalar p); diff --git a/lib/src/Uncertainty/Distribution/CMakeLists.txt b/lib/src/Uncertainty/Distribution/CMakeLists.txt index 3aba6be69b..bb2832123b 100644 --- a/lib/src/Uncertainty/Distribution/CMakeLists.txt +++ b/lib/src/Uncertainty/Distribution/CMakeLists.txt @@ -118,7 +118,7 @@ ot_add_source_file (MixedHistogramUserDefined.cxx) ot_add_source_file (Mixture.cxx) ot_add_source_file (Multinomial.cxx) ot_add_source_file (MultinomialFactory.cxx) -ot_add_source_file (NegativeBinomial.cxx) +ot_add_source_file (Polya.cxx) ot_add_source_file (NegativeBinomialFactory.cxx) ot_add_source_file (NonCentralChiSquare.cxx) ot_add_source_file (NonCentralStudent.cxx) @@ -293,7 +293,7 @@ ot_install_header_file (MixedHistogramUserDefined.hxx) ot_install_header_file (Mixture.hxx) ot_install_header_file (MultinomialFactory.hxx) ot_install_header_file (Multinomial.hxx) -ot_install_header_file (NegativeBinomial.hxx) +ot_install_header_file (Polya.hxx) ot_install_header_file (NegativeBinomialFactory.hxx) ot_install_header_file (NonCentralChiSquare.hxx) ot_install_header_file (NonCentralStudent.hxx) diff --git a/lib/src/Uncertainty/Distribution/NegativeBinomialFactory.cxx b/lib/src/Uncertainty/Distribution/NegativeBinomialFactory.cxx index 0d394bf0aa..ae8e6e84c9 100644 --- a/lib/src/Uncertainty/Distribution/NegativeBinomialFactory.cxx +++ b/lib/src/Uncertainty/Distribution/NegativeBinomialFactory.cxx @@ -1,6 +1,6 @@ // -*- C++ -*- /** - * @brief Factory for NegativeBinomial distribution + * @brief Factory for Polya distribution * * Copyright 2005-2024 Airbus-EDF-IMACS-ONERA-Phimeca * @@ -91,21 +91,21 @@ Distribution NegativeBinomialFactory::build() const return buildAsNegativeBinomial().clone(); } -NegativeBinomial NegativeBinomialFactory::buildAsNegativeBinomial(const Sample & sample) const +Polya NegativeBinomialFactory::buildAsNegativeBinomial(const Sample & sample) const { const UnsignedInteger size = sample.getSize(); - if (size < 2) throw InvalidArgumentException(HERE) << "Error: cannot build a NegativeBinomial distribution from a sample of size < 2"; - if (sample.getDimension() != 1) throw InvalidArgumentException(HERE) << "Error: can build a NegativeBinomial distribution only from a sample of dimension 1, here dimension=" << sample.getDimension(); + if (size < 2) throw InvalidArgumentException(HERE) << "Error: cannot build a Polya distribution from a sample of size < 2"; + if (sample.getDimension() != 1) throw InvalidArgumentException(HERE) << "Error: can build a Polya distribution only from a sample of dimension 1, here dimension=" << sample.getDimension(); Scalar mean = 0.0; Scalar var = 0.0; const Scalar supportEpsilon = ResourceMap::GetAsScalar("DiscreteDistribution-SupportEpsilon"); for (UnsignedInteger i = 0; i < size; ++i) { const Scalar x = sample(i, 0); - if (!SpecFunc::IsNormal(x)) throw InvalidArgumentException(HERE) << "Error: cannot build a NegativeBinomial distribution if data contains NaN or Inf"; + if (!SpecFunc::IsNormal(x)) throw InvalidArgumentException(HERE) << "Error: cannot build a Polya distribution if data contains NaN or Inf"; const int iX(static_cast(round(x))); // The sample must be made of nonnegative integral values - if (std::abs(x - iX) > supportEpsilon || (iX < 0)) throw InvalidArgumentException(HERE) << "Error: can build a NegativeBinomial distribution only from a sample made of nonnegative integers, here x=" << x; + if (std::abs(x - iX) > supportEpsilon || (iX < 0)) throw InvalidArgumentException(HERE) << "Error: can build a Polya distribution only from a sample made of nonnegative integers, here x=" << x; var = i * var / (i + 1.0) + (1.0 - 1.0 / (i + 1.0)) * (mean - x) * (mean - x) / (i + 1.0); mean = (x + i * mean) / (i + 1.0); } @@ -139,28 +139,28 @@ NegativeBinomial NegativeBinomialFactory::buildAsNegativeBinomial(const Sample & const Scalar r = solver.solve(f, 0.0, a, b, fA, fB); // Corresponding p estimate const Scalar p = 1.0 / (r / mean + 1.0); - NegativeBinomial result(r, p); + Polya result(r, p); result.setDescription(sample.getDescription()); return result; } -NegativeBinomial NegativeBinomialFactory::buildAsNegativeBinomial(const Point & parameters) const +Polya NegativeBinomialFactory::buildAsNegativeBinomial(const Point & parameters) const { try { - NegativeBinomial distribution; + Polya distribution; distribution.setParameter(parameters); return distribution; } catch (const InvalidArgumentException &) { - throw InvalidArgumentException(HERE) << "Error: cannot build a NegativeBinomial distribution from the given parameters"; + throw InvalidArgumentException(HERE) << "Error: cannot build a Polya distribution from the given parameters"; } } -NegativeBinomial NegativeBinomialFactory::buildAsNegativeBinomial() const +Polya NegativeBinomialFactory::buildAsNegativeBinomial() const { - return NegativeBinomial(); + return Polya(); } END_NAMESPACE_OPENTURNS diff --git a/lib/src/Uncertainty/Distribution/NegativeBinomial.cxx b/lib/src/Uncertainty/Distribution/Polya.cxx similarity index 73% rename from lib/src/Uncertainty/Distribution/NegativeBinomial.cxx rename to lib/src/Uncertainty/Distribution/Polya.cxx index a894da093e..b48b630e22 100644 --- a/lib/src/Uncertainty/Distribution/NegativeBinomial.cxx +++ b/lib/src/Uncertainty/Distribution/Polya.cxx @@ -1,6 +1,6 @@ // -*- C++ -*- /** - * @brief The NegativeBinomial distribution + * @brief The Polya distribution * * Copyright 2005-2024 Airbus-EDF-IMACS-ONERA-Phimeca * @@ -19,7 +19,7 @@ * */ #include -#include "openturns/NegativeBinomial.hxx" +#include "openturns/Polya.hxx" #include "openturns/SpecFunc.hxx" #include "openturns/DistFunc.hxx" #include "openturns/RandomGenerator.hxx" @@ -28,31 +28,31 @@ BEGIN_NAMESPACE_OPENTURNS -CLASSNAMEINIT(NegativeBinomial) +CLASSNAMEINIT(Polya) -static const Factory Factory_NegativeBinomial; +static const Factory Factory_Polya; /* Default constructor */ -NegativeBinomial::NegativeBinomial() +Polya::Polya() : DiscreteDistribution() , r_(1.0) , p_(0.5) { - setName( "NegativeBinomial" ); - // We set the dimension of the NegativeBinomial distribution + setName( "Polya" ); + // We set the dimension of the Polya distribution setDimension( 1 ); computeRange(); } /* Parameters constructor */ -NegativeBinomial::NegativeBinomial(const Scalar r, +Polya::Polya(const Scalar r, const Scalar p) : DiscreteDistribution() , r_(r) , p_(p) { - setName( "NegativeBinomial" ); - // We set the dimension of the NegativeBinomial distribution + setName( "Polya" ); + // We set the dimension of the Polya distribution setR(r); setP(p); setDimension( 1 ); @@ -60,23 +60,23 @@ NegativeBinomial::NegativeBinomial(const Scalar r, } /* Comparison operator */ -Bool NegativeBinomial::operator ==(const NegativeBinomial & other) const +Bool Polya::operator ==(const Polya & other) const { if (this == &other) return true; return (r_ == other.r_) && (p_ == other.p_); } -Bool NegativeBinomial::equals(const DistributionImplementation & other) const +Bool Polya::equals(const DistributionImplementation & other) const { - const NegativeBinomial* p_other = dynamic_cast(&other); + const Polya* p_other = dynamic_cast(&other); return p_other && (*this == *p_other); } /* String converter */ -String NegativeBinomial::__repr__() const +String Polya::__repr__() const { OSS oss; - oss << "class=" << NegativeBinomial::GetClassName() + oss << "class=" << Polya::GetClassName() << " name=" << getName() << " dimension=" << getDimension() << " r=" << r_ @@ -84,7 +84,7 @@ String NegativeBinomial::__repr__() const return oss; } -String NegativeBinomial::__str__(const String & ) const +String Polya::__str__(const String & ) const { OSS oss; oss << getClassName() << "(r = " << r_ << ", p = " << p_ << ")"; @@ -92,20 +92,20 @@ String NegativeBinomial::__str__(const String & ) const } /* Virtual constructor */ -NegativeBinomial * NegativeBinomial::clone() const +Polya * Polya::clone() const { - return new NegativeBinomial(*this); + return new Polya(*this); } /* Get one realization of the distribution */ -Point NegativeBinomial::getRealization() const +Point Polya::getRealization() const { return Point(1, DistFunc::rPoisson(DistFunc::rGamma(r_) * p_ / (1.0 - p_))); } /* Get the PDF of the distribution */ -Scalar NegativeBinomial::computePDF(const Point & point) const +Scalar Polya::computePDF(const Point & point) const { if (point.getDimension() != 1) throw InvalidArgumentException(HERE) << "Error: the given point must have dimension=1, here dimension=" << point.getDimension(); @@ -116,7 +116,7 @@ Scalar NegativeBinomial::computePDF(const Point & point) const /* Get the CDF of the distribution */ -Scalar NegativeBinomial::computeCDF(const Point & point) const +Scalar Polya::computeCDF(const Point & point) const { if (point.getDimension() != 1) throw InvalidArgumentException(HERE) << "Error: the given point must have dimension=1, here dimension=" << point.getDimension(); @@ -126,7 +126,7 @@ Scalar NegativeBinomial::computeCDF(const Point & point) const return DistFunc::pBeta(floor(k) + 1, r_, p_, true); } -Scalar NegativeBinomial::computeComplementaryCDF(const Point & point) const +Scalar Polya::computeComplementaryCDF(const Point & point) const { if (point.getDimension() != 1) throw InvalidArgumentException(HERE) << "Error: the given point must have dimension=1, here dimension=" << point.getDimension(); @@ -138,54 +138,54 @@ Scalar NegativeBinomial::computeComplementaryCDF(const Point & point) const } /* Get the PDF gradient of the distribution */ -Point NegativeBinomial::computePDFGradient(const Point & point) const +Point Polya::computePDFGradient(const Point & point) const { if (point.getDimension() != 1) throw InvalidArgumentException(HERE) << "Error: the given point must have dimension=1, here dimension=" << point.getDimension(); const Scalar k = point[0]; Point pdfGradient(1, 0.0); if ((k < -supportEpsilon_) || (std::abs(k - round(k)) > supportEpsilon_)) return pdfGradient; - throw NotYetImplementedException(HERE) << "In NegativeBinomial::computePDFGradient(const Point & point) const"; + throw NotYetImplementedException(HERE) << "In Polya::computePDFGradient(const Point & point) const"; } /* Get the CDF gradient of the distribution */ -Point NegativeBinomial::computeCDFGradient(const Point & point) const +Point Polya::computeCDFGradient(const Point & point) const { if (point.getDimension() != 1) throw InvalidArgumentException(HERE) << "Error: the given point must have dimension=1, here dimension=" << point.getDimension(); const Scalar k = point[0]; if (k < -supportEpsilon_) return Point(1, 0.0); - throw NotYetImplementedException(HERE) << "In NegativeBinomial::computeCDFGradient(const Point & point) const"; + throw NotYetImplementedException(HERE) << "In Polya::computeCDFGradient(const Point & point) const"; } /* Compute the mean of the distribution */ -void NegativeBinomial::computeMean() const +void Polya::computeMean() const { mean_ = Point(1, r_ * p_ / (1.0 - p_)); isAlreadyComputedMean_ = true; } /* Get the standard deviation of the distribution */ -Point NegativeBinomial::getStandardDeviation() const +Point Polya::getStandardDeviation() const { return Point(1, std::sqrt(r_ * p_) / (1.0 - p_)); } /* Get the skewness of the distribution */ -Point NegativeBinomial::getSkewness() const +Point Polya::getSkewness() const { return Point(1, (1.0 + p_) / std::sqrt(p_ * r_)); } /* Get the kurtosis of the distribution */ -Point NegativeBinomial::getKurtosis() const +Point Polya::getKurtosis() const { return Point(1, 3.0 + 6.0 / r_ + std::pow(1.0 - p_, 2.0) / (p_ * r_)); } /* Compute the covariance of the distribution */ -void NegativeBinomial::computeCovariance() const +void Polya::computeCovariance() const { covariance_ = CovarianceMatrix(1); covariance_(0, 0) = r_ * p_ / std::pow(1.0 - p_, 2.0); @@ -193,7 +193,7 @@ void NegativeBinomial::computeCovariance() const } /* Get the support of a discrete distribution that intersect a given interval */ -Sample NegativeBinomial::getSupport(const Interval & interval) const +Sample Polya::getSupport(const Interval & interval) const { if (interval.getDimension() != getDimension()) throw InvalidArgumentException(HERE) << "Error: the given interval has a dimension that does not match the distribution dimension."; const SignedInteger kMin = static_cast< SignedInteger > (std::max(0.0, ceil(interval.getLowerBound()[0]))); @@ -205,7 +205,7 @@ Sample NegativeBinomial::getSupport(const Interval & interval) const } /* Parameters value accessor */ -Point NegativeBinomial::getParameter() const +Point Polya::getParameter() const { Point point(2); point[0] = r_; @@ -213,16 +213,16 @@ Point NegativeBinomial::getParameter() const return point; } -void NegativeBinomial::setParameter(const Point & parameter) +void Polya::setParameter(const Point & parameter) { if (parameter.getSize() != 2) throw InvalidArgumentException(HERE) << "Error: expected 2 values, got " << parameter.getSize(); const Scalar w = getWeight(); - *this = NegativeBinomial(parameter[0], parameter[1]); + *this = Polya(parameter[0], parameter[1]); setWeight(w); } /* Parameters description accessor */ -Description NegativeBinomial::getParameterDescription() const +Description Polya::getParameterDescription() const { Description description(2); description[0] = "r"; @@ -231,7 +231,7 @@ Description NegativeBinomial::getParameterDescription() const } /* P accessor */ -void NegativeBinomial::setP(const Scalar p) +void Polya::setP(const Scalar p) { if ((p <= 0.0) || (p >= 1.0)) throw InvalidArgumentException(HERE) << "Error: p must be in (0, 1), here p=" << p; if (p != p_) @@ -244,13 +244,13 @@ void NegativeBinomial::setP(const Scalar p) } /* P accessor */ -Scalar NegativeBinomial::getP() const +Scalar Polya::getP() const { return p_; } /* N accessor */ -void NegativeBinomial::setR(const Scalar r) +void Polya::setR(const Scalar r) { if (!(r > 0.0)) throw InvalidArgumentException(HERE) << "Error: r must be > 0, here r=" << r; if (r != r_) @@ -263,13 +263,13 @@ void NegativeBinomial::setR(const Scalar r) } /* N accessor */ -Scalar NegativeBinomial::getR() const +Scalar Polya::getR() const { return r_; } /* Compute the numerical range of the distribution given the parameters values */ -void NegativeBinomial::computeRange() +void Polya::computeRange() { const Point lowerBound(1, 0.0); const Point upperBound(computeUpperBound()); @@ -279,10 +279,10 @@ void NegativeBinomial::computeRange() } /* Get the quantile of the distribution */ -Scalar NegativeBinomial::computeScalarQuantile(const Scalar prob, +Scalar Polya::computeScalarQuantile(const Scalar prob, const Bool tail) const { - LOGDEBUG(OSS() << "in NegativeBinomial::computeScalarQuantile, prob=" << prob << ", tail=" << tail); + LOGDEBUG(OSS() << "in Polya::computeScalarQuantile, prob=" << prob << ", tail=" << tail); if (!((prob >= 0.0) && (prob <= 1.0))) throw InvalidArgumentException(HERE) << "computeScalarQuantile expected prob to belong to [0,1], but is " << prob; if (tail ? (prob == 1.0) : (prob == 0.0)) return 0.0; @@ -294,7 +294,7 @@ Scalar NegativeBinomial::computeScalarQuantile(const Scalar prob, Scalar quantile = round(getMean()[0] + getStandardDeviation()[0] * (qNorm + (qNorm * qNorm - 1.0) * gamma1 / 6.0 + qNorm * (qNorm * qNorm - 3.0) * gamma2 / 24.0 - qNorm * (2.0 * qNorm * qNorm - 5.0) * gamma1 * gamma1 / 36.0)); if (quantile < 0.0) quantile = 0.0; Scalar cdf = tail ? computeComplementaryCDF(quantile) : computeCDF(quantile); - LOGDEBUG(OSS() << "in NegativeBinomial::computeScalarQuantile, Cornish-Fisher estimate=" << quantile << ", cdf=" << cdf); + LOGDEBUG(OSS() << "in Polya::computeScalarQuantile, Cornish-Fisher estimate=" << quantile << ", cdf=" << cdf); Scalar oldCDF = cdf; const Scalar step = tail ? -1.0 : 1.0; while (cdf >= prob) @@ -302,12 +302,12 @@ Scalar NegativeBinomial::computeScalarQuantile(const Scalar prob, quantile -= step; oldCDF = cdf; cdf = tail ? computeComplementaryCDF(quantile) : computeCDF(quantile); - LOGDEBUG(OSS() << "in NegativeBinomial::computeScalarQuantile, backward search, quantile=" << quantile << ", cdf=" << cdf); + LOGDEBUG(OSS() << "in Polya::computeScalarQuantile, backward search, quantile=" << quantile << ", cdf=" << cdf); } if (cdf < oldCDF) { quantile += step; - LOGDEBUG(OSS() << "in NegativeBinomial::computeScalarQuantile, final quantile=" << quantile); + LOGDEBUG(OSS() << "in Polya::computeScalarQuantile, final quantile=" << quantile); return quantile; } while (cdf < prob) @@ -315,40 +315,40 @@ Scalar NegativeBinomial::computeScalarQuantile(const Scalar prob, quantile += step; oldCDF = cdf; cdf = tail ? computeComplementaryCDF(quantile) : computeCDF(quantile); - LOGDEBUG(OSS() << "in NegativeBinomial::computeScalarQuantile, forward search, quantile=" << quantile << ", cdf=" << cdf); + LOGDEBUG(OSS() << "in Polya::computeScalarQuantile, forward search, quantile=" << quantile << ", cdf=" << cdf); } - LOGDEBUG(OSS() << "in NegativeBinomial::computeScalarQuantile, final quantile=" << quantile); + LOGDEBUG(OSS() << "in Polya::computeScalarQuantile, final quantile=" << quantile); return quantile; } /* Get the characteristic function of the distribution, i.e. phi(u) = E(exp(I*u*X)) */ -Complex NegativeBinomial::computeCharacteristicFunction(const Scalar x) const +Complex Polya::computeCharacteristicFunction(const Scalar x) const { const Complex value((1.0 - p_) / (1.0 - p_ * std::exp(Complex(0.0, x)))); return std::pow(value, r_); } -Complex NegativeBinomial::computeLogCharacteristicFunction(const Scalar x) const +Complex Polya::computeLogCharacteristicFunction(const Scalar x) const { const Complex value((1.0 - p_) / (1.0 - p_ * std::exp(Complex(0.0, x)))); return Complex(r_) * std::log(value); } /* Get the generating function of the distribution, i.e. psi(z) = E(z^X) */ -Complex NegativeBinomial::computeGeneratingFunction(const Complex & z) const +Complex Polya::computeGeneratingFunction(const Complex & z) const { const Complex value((1.0 - p_) / (1.0 - p_ * z)); return std::pow(value, r_); } -Complex NegativeBinomial::computeLogGeneratingFunction(const Complex & z) const +Complex Polya::computeLogGeneratingFunction(const Complex & z) const { const Complex value((1.0 - p_) / (1.0 - p_ * z)); return Complex(r_) * std::log(value); } /* Method save() stores the object through the StorageManager */ -void NegativeBinomial::save(Advocate & adv) const +void Polya::save(Advocate & adv) const { DiscreteDistribution::save(adv); adv.saveAttribute( "r_", r_ ); @@ -356,7 +356,7 @@ void NegativeBinomial::save(Advocate & adv) const } /* Method load() reloads the object from the StorageManager */ -void NegativeBinomial::load(Advocate & adv) +void Polya::load(Advocate & adv) { DiscreteDistribution::load(adv); adv.loadAttribute( "r_", r_ ); @@ -364,4 +364,8 @@ void NegativeBinomial::load(Advocate & adv) computeRange(); } +CLASSNAMEINIT(NegativeBinomial) + +static const Factory Factory_NegativeBinomial; + END_NAMESPACE_OPENTURNS diff --git a/lib/src/Uncertainty/Distribution/openturns/NegativeBinomialFactory.hxx b/lib/src/Uncertainty/Distribution/openturns/NegativeBinomialFactory.hxx index a4da8190b0..ecea5fe599 100644 --- a/lib/src/Uncertainty/Distribution/openturns/NegativeBinomialFactory.hxx +++ b/lib/src/Uncertainty/Distribution/openturns/NegativeBinomialFactory.hxx @@ -1,6 +1,6 @@ // -*- C++ -*- /** - * @brief Factory for NegativeBinomial distribution + * @brief Factory for Polya distribution * * Copyright 2005-2024 Airbus-EDF-IMACS-ONERA-Phimeca * @@ -23,7 +23,7 @@ #include "openturns/OTprivate.hxx" #include "openturns/DistributionFactoryImplementation.hxx" -#include "openturns/NegativeBinomial.hxx" +#include "openturns/Polya.hxx" BEGIN_NAMESPACE_OPENTURNS @@ -48,9 +48,9 @@ public: Distribution build(const Sample & sample) const override; Distribution build(const Point & parameters) const override; Distribution build() const override; - NegativeBinomial buildAsNegativeBinomial(const Sample & sample) const; - NegativeBinomial buildAsNegativeBinomial(const Point & parameters) const; - NegativeBinomial buildAsNegativeBinomial() const; + Polya buildAsNegativeBinomial(const Sample & sample) const; + Polya buildAsNegativeBinomial(const Point & parameters) const; + Polya buildAsNegativeBinomial() const; }; /* class NegativeBinomialFactory */ diff --git a/lib/src/Uncertainty/Distribution/openturns/OTDistribution.hxx b/lib/src/Uncertainty/Distribution/openturns/OTDistribution.hxx index b03ac5f4a6..49396d4ce7 100644 --- a/lib/src/Uncertainty/Distribution/openturns/OTDistribution.hxx +++ b/lib/src/Uncertainty/Distribution/openturns/OTDistribution.hxx @@ -127,7 +127,7 @@ #include "openturns/Mixture.hxx" #include "openturns/Multinomial.hxx" #include "openturns/MultinomialFactory.hxx" -#include "openturns/NegativeBinomial.hxx" +#include "openturns/Polya.hxx" #include "openturns/NegativeBinomialFactory.hxx" #include "openturns/NonCentralChiSquare.hxx" #include "openturns/NonCentralStudent.hxx" diff --git a/lib/src/Uncertainty/Distribution/openturns/NegativeBinomial.hxx b/lib/src/Uncertainty/Distribution/openturns/Polya.hxx similarity index 86% rename from lib/src/Uncertainty/Distribution/openturns/NegativeBinomial.hxx rename to lib/src/Uncertainty/Distribution/openturns/Polya.hxx index b205dc32b0..75aa0db53f 100644 --- a/lib/src/Uncertainty/Distribution/openturns/NegativeBinomial.hxx +++ b/lib/src/Uncertainty/Distribution/openturns/Polya.hxx @@ -1,6 +1,6 @@ // -*- C++ -*- /** - * @brief The NegativeBinomial distribution + * @brief The Polya distribution * * Copyright 2005-2024 Airbus-EDF-IMACS-ONERA-Phimeca * @@ -18,8 +18,8 @@ * along with this library. If not, see . * */ -#ifndef OPENTURNS_NEGATIVEBINOMIAL_HXX -#define OPENTURNS_NEGATIVEBINOMIAL_HXX +#ifndef OPENTURNS_POLYA_HXX +#define OPENTURNS_POLYA_HXX #include "openturns/OTprivate.hxx" #include "openturns/DiscreteDistribution.hxx" @@ -27,26 +27,26 @@ BEGIN_NAMESPACE_OPENTURNS /** - * @class NegativeBinomial + * @class Polya * - * The NegativeBinomial distribution. + * The Polya distribution. */ -class OT_API NegativeBinomial +class OT_API Polya : public DiscreteDistribution { CLASSNAME public: /** Default constructor */ - NegativeBinomial(); + Polya(); /** Parameters constructor */ - NegativeBinomial(const Scalar r, - const Scalar p); + Polya(const Scalar r, + const Scalar p); /** Comparison operator */ using DiscreteDistribution::operator ==; - Bool operator ==(const NegativeBinomial & other) const; + Bool operator ==(const Polya & other) const; protected: Bool equals(const DistributionImplementation & other) const override; public: @@ -58,7 +58,7 @@ public: /* Interface inherited from Distribution */ /** Virtual constructor */ - NegativeBinomial * clone() const override; + Polya * clone() const override; /** Get one realization of the distribution */ Point getRealization() const override; @@ -109,7 +109,7 @@ public: /** Parameters description accessor */ Description getParameterDescription() const override; - /* Interface specific to NegativeBinomial */ + /* Interface specific to Polya */ /** P accessor */ void setP(const Scalar p); @@ -141,15 +141,29 @@ private: /** Compute the numerical range of the distribution given the parameters values */ void computeRange() override; - /** The maximum value of the NegativeBinomial distribution */ + /** The maximum value of the Polya distribution */ Scalar r_; - /** The probability parameter of the NegativeBinomial distribution */ + /** The probability parameter of the Polya distribution */ Scalar p_; -}; /* class NegativeBinomial */ +}; /* class Polya */ + +// @deprecated +class OT_API NegativeBinomial + : public Polya +{ + CLASSNAME +public: + NegativeBinomial() + : Polya() {} + + NegativeBinomial(const Scalar r, + const Scalar p) + : Polya(r, p) {} +}; END_NAMESPACE_OPENTURNS -#endif /* OPENTURNS_NEGATIVEBINOMIAL_HXX */ +#endif /* OPENTURNS_POLYA_HXX */ diff --git a/lib/test/CMakeLists.txt b/lib/test/CMakeLists.txt index 6c56480cb9..9f876ab840 100644 --- a/lib/test/CMakeLists.txt +++ b/lib/test/CMakeLists.txt @@ -412,7 +412,7 @@ ot_check_test (MixedHistogramUserDefined_std) ot_check_test (Mixture_std) ot_check_test (Multinomial_std) ot_check_test (MultinomialFactory_std) -ot_check_test (NegativeBinomial_std) +ot_check_test (Polya_std) ot_check_test (NegativeBinomialFactory_std) ot_check_test (NonCentralChiSquare_std) if (Boost_FOUND) diff --git a/lib/test/t_MeixnerFactory_std.expout b/lib/test/t_MeixnerFactory_std.expout index 5b7ebf7a34..d4b6598dbe 100644 --- a/lib/test/t_MeixnerFactory_std.expout +++ b/lib/test/t_MeixnerFactory_std.expout @@ -1,4 +1,4 @@ -meixner=class=MeixnerFactory r=10 p=0.3 measure=class=NegativeBinomial name=NegativeBinomial dimension=1 r=10 p=0.3 +meixner=class=MeixnerFactory r=10 p=0.3 measure=class=Polya name=Polya dimension=1 r=10 p=0.3 meixner(0)=1 meixner(1)=1.73205 - 0.404145 * X meixner(2)=2.22486 - 1.14839 * X + 0.110119 * X^2 diff --git a/lib/test/t_NegativeBinomialFactory_std.cxx b/lib/test/t_NegativeBinomialFactory_std.cxx index 991fac3b50..dd4e37236d 100644 --- a/lib/test/t_NegativeBinomialFactory_std.cxx +++ b/lib/test/t_NegativeBinomialFactory_std.cxx @@ -1,6 +1,6 @@ // -*- C++ -*- /** - * @brief The test file of class NegativeBinomial for standard methods + * @brief The test file of class Polya for standard methods * * Copyright 2005-2024 Airbus-EDF-IMACS-ONERA-Phimeca * @@ -32,7 +32,7 @@ int main(int, char *[]) try { - NegativeBinomial distribution(15, 0.7); + Polya distribution(15, 0.7); UnsignedInteger size = 10000; Sample sample(distribution.getSample(size)); NegativeBinomialFactory factory; @@ -43,13 +43,13 @@ int main(int, char *[]) fullprint << "Default distribution=" << estimatedDistribution << std::endl; estimatedDistribution = factory.build(distribution.getParameter()); fullprint << "Distribution from parameters=" << estimatedDistribution << std::endl; - NegativeBinomial estimatedNegativeBinomial(factory.buildAsNegativeBinomial(sample)); - fullprint << "NegativeBinomial =" << distribution << std::endl; + Polya estimatedNegativeBinomial(factory.buildAsNegativeBinomial(sample)); + fullprint << "Polya =" << distribution << std::endl; fullprint << "Estimated negativeBinomial=" << estimatedNegativeBinomial << std::endl; estimatedNegativeBinomial = factory.buildAsNegativeBinomial(); fullprint << "Default negativeBinomial=" << estimatedNegativeBinomial << std::endl; estimatedNegativeBinomial = factory.buildAsNegativeBinomial(distribution.getParameter()); - fullprint << "NegativeBinomial from parameters=" << estimatedNegativeBinomial << std::endl; + fullprint << "Polya from parameters=" << estimatedNegativeBinomial << std::endl; } catch (TestFailed & ex) { diff --git a/lib/test/t_NegativeBinomialFactory_std.expout b/lib/test/t_NegativeBinomialFactory_std.expout index 247b4beae4..55a8a5eb74 100644 --- a/lib/test/t_NegativeBinomialFactory_std.expout +++ b/lib/test/t_NegativeBinomialFactory_std.expout @@ -1,8 +1,8 @@ -Distribution =class=NegativeBinomial name=NegativeBinomial dimension=1 r=15 p=0.7 -Estimated distribution=class=NegativeBinomial name=NegativeBinomial dimension=1 r=15.0803 p=0.699114 -Default distribution=class=NegativeBinomial name=NegativeBinomial dimension=1 r=1 p=0.5 -Distribution from parameters=class=NegativeBinomial name=NegativeBinomial dimension=1 r=15 p=0.7 -NegativeBinomial =class=NegativeBinomial name=NegativeBinomial dimension=1 r=15 p=0.7 -Estimated negativeBinomial=class=NegativeBinomial name=NegativeBinomial dimension=1 r=15.0803 p=0.699114 -Default negativeBinomial=class=NegativeBinomial name=NegativeBinomial dimension=1 r=1 p=0.5 -NegativeBinomial from parameters=class=NegativeBinomial name=NegativeBinomial dimension=1 r=15 p=0.7 +Distribution =class=Polya name=Polya dimension=1 r=15 p=0.7 +Estimated distribution=class=Polya name=Polya dimension=1 r=15.0803 p=0.699114 +Default distribution=class=Polya name=Polya dimension=1 r=1 p=0.5 +Distribution from parameters=class=Polya name=Polya dimension=1 r=15 p=0.7 +Polya =class=Polya name=Polya dimension=1 r=15 p=0.7 +Estimated negativeBinomial=class=Polya name=Polya dimension=1 r=15.0803 p=0.699114 +Default negativeBinomial=class=Polya name=Polya dimension=1 r=1 p=0.5 +Polya from parameters=class=Polya name=Polya dimension=1 r=15 p=0.7 diff --git a/lib/test/t_NegativeBinomial_std.cxx b/lib/test/t_Polya_std.cxx similarity index 94% rename from lib/test/t_NegativeBinomial_std.cxx rename to lib/test/t_Polya_std.cxx index 221cd188ad..cceb70e5f1 100644 --- a/lib/test/t_NegativeBinomial_std.cxx +++ b/lib/test/t_Polya_std.cxx @@ -1,6 +1,6 @@ // -*- C++ -*- /** - * @brief The test file of class NegativeBinomial for standard methods + * @brief The test file of class Polya for standard methods * * Copyright 2005-2024 Airbus-EDF-IMACS-ONERA-Phimeca * @@ -24,10 +24,10 @@ using namespace OT; using namespace OT::Test; -class TestObject : public NegativeBinomial +class TestObject : public Polya { public: - TestObject() : NegativeBinomial(4.5, 0.7) {} + TestObject() : Polya(4.5, 0.7) {} virtual ~TestObject() {} }; @@ -44,7 +44,7 @@ int main(int, char *[]) checkClassWithClassName(); // Instantiate one distribution object - NegativeBinomial distribution(4.5, 0.7); + Polya distribution(4.5, 0.7); fullprint << "Distribution " << distribution << std::endl; std::cout << "Distribution " << distribution << std::endl; @@ -117,7 +117,7 @@ int main(int, char *[]) fullprint << "spearman=" << spearman << std::endl; CovarianceMatrix kendall = distribution.getKendallTau(); fullprint << "kendall=" << kendall << std::endl; - NegativeBinomial::PointWithDescriptionCollection parameters = distribution.getParametersCollection(); + Polya::PointWithDescriptionCollection parameters = distribution.getParametersCollection(); fullprint << "parameters=" << parameters << std::endl; fullprint << "Standard representative=" << distribution.getStandardRepresentative().__str__() << std::endl; } diff --git a/lib/test/t_NegativeBinomial_std.expout b/lib/test/t_Polya_std.expout similarity index 84% rename from lib/test/t_NegativeBinomial_std.expout rename to lib/test/t_Polya_std.expout index 2923c71cac..792d0a8c40 100644 --- a/lib/test/t_NegativeBinomial_std.expout +++ b/lib/test/t_Polya_std.expout @@ -1,14 +1,14 @@ -Testing class NegativeBinomial +Testing class Polya checkConstructorAndDestructor() checkCopyConstructor() streamObject(const T & anObject) -class=NegativeBinomial name=NegativeBinomial dimension=1 r=4.5 p=0.7 +class=Polya name=Polya dimension=1 r=4.5 p=0.7 streamObject(const T & anObject) -class=NegativeBinomial name=NegativeBinomial dimension=1 r=4.5 p=0.7 +class=Polya name=Polya dimension=1 r=4.5 p=0.7 areSameObjects(const T & firstObject, const T & secondObject) areDifferentObjects(const T & firstObject, const T & secondObject) -Distribution class=NegativeBinomial name=NegativeBinomial dimension=1 r=4.5 p=0.7 -Distribution NegativeBinomial(r = 4.5, p = 0.7) +Distribution class=Polya name=Polya dimension=1 r=4.5 p=0.7 +Distribution Polya(r = 4.5, p = 0.7) Elliptical = false Continuous = false oneRealization=class=Point name=Unnamed dimension=1 values=[7] @@ -39,4 +39,4 @@ correlation=class=CovarianceMatrix dimension=1 implementation=class=MatrixImplem spearman=class=CovarianceMatrix dimension=1 implementation=class=MatrixImplementation name=Unnamed rows=1 columns=1 values=[1] kendall=class=CovarianceMatrix dimension=1 implementation=class=MatrixImplementation name=Unnamed rows=1 columns=1 values=[1] parameters=[[r : 4.5, p : 0.7]] -Standard representative=NegativeBinomial(r = 4.5, p = 0.7) +Standard representative=Polya(r = 4.5, p = 0.7) diff --git a/python/doc/pyplots/NegativeBinomial.py b/python/doc/pyplots/Polya.py similarity index 91% rename from python/doc/pyplots/NegativeBinomial.py rename to python/doc/pyplots/Polya.py index 6df4406114..be0b47622c 100644 --- a/python/doc/pyplots/NegativeBinomial.py +++ b/python/doc/pyplots/Polya.py @@ -7,7 +7,7 @@ palette = ot.Drawable.BuildDefaultPalette(10) for i, v in enumerate([(2, 0.83), (4, 0.66), (20, 0.33)]): r, p = v - distribution = ot.NegativeBinomial(r, p) + distribution = ot.Polya(r, p) pdf_curve = distribution.drawPDF().getDrawable(0) cdf_curve = distribution.drawCDF().getDrawable(0) pdf_curve.setColor(palette[i]) @@ -21,4 +21,4 @@ cdf_axis = fig.add_subplot(122) View(pdf_graph, figure=fig, axes=[pdf_axis], add_legend=True) View(cdf_graph, figure=fig, axes=[cdf_axis], add_legend=True) -fig.suptitle("NegativeBinomial(r,p)") +fig.suptitle("Polya(r,p)") diff --git a/python/doc/theory/numerical_methods/distribution_realization.rst b/python/doc/theory/numerical_methods/distribution_realization.rst index 08d6a9e45b..cd798704fd 100644 --- a/python/doc/theory/numerical_methods/distribution_realization.rst +++ b/python/doc/theory/numerical_methods/distribution_realization.rst @@ -164,7 +164,7 @@ The techniques implemented in each distribution are: - Mixture: Transformation. - MultiNomial: Conditional CDF inversion. - Non Central Chi Square: Transformation. -- NegativeBinomial: Conditional simulation (Poisson|Gamma) +- Polya: Conditional simulation (Poisson|Gamma) - Non Central Student: Transformation. - NormalCopula: Transformation of independent Normal realizations. - Normal: diff --git a/python/doc/user_manual/probabilistic_modelling.rst b/python/doc/user_manual/probabilistic_modelling.rst index 3bbfc43da1..f761c81bbb 100644 --- a/python/doc/user_manual/probabilistic_modelling.rst +++ b/python/doc/user_manual/probabilistic_modelling.rst @@ -118,7 +118,7 @@ Discrete parametric distributions KPermutationsDistribution :template: classWithPlot.rst_t - NegativeBinomial + Polya :template: Distribution.rst_t Poisson diff --git a/python/src/CMakeLists.txt b/python/src/CMakeLists.txt index 4bf47215e1..ddedb091b8 100644 --- a/python/src/CMakeLists.txt +++ b/python/src/CMakeLists.txt @@ -709,7 +709,7 @@ ot_add_python_module(dist_bundle2 dist_bundle2_module.i DeconditionedDistribution.i DeconditionedDistribution_doc.i.in Multinomial.i Multinomial_doc.i.in MultinomialFactory.i MultinomialFactory_doc.i.in - NegativeBinomial.i NegativeBinomial_doc.i.in + Polya.i Polya_doc.i.in NegativeBinomialFactory.i NegativeBinomialFactory_doc.i.in NonCentralChiSquare.i NonCentralChiSquare_doc.i.in NonCentralStudent.i NonCentralStudent_doc.i.in diff --git a/python/src/MeixnerFactory_doc.i.in b/python/src/MeixnerFactory_doc.i.in index 4f211be324..92f1c204d9 100644 --- a/python/src/MeixnerFactory_doc.i.in +++ b/python/src/MeixnerFactory_doc.i.in @@ -1,15 +1,15 @@ %feature("docstring") OT::MeixnerFactory "Meixner specific orthonormal univariate polynomial family. -For the :class:`~openturns.NegativeBinomial` distribution. +For the :class:`~openturns.Polya` distribution. Parameters ---------- r : float, :math:`r > 0` - Number of failures parameter of the :class:`~openturns.NegativeBinomial` + Number of failures parameter of the :class:`~openturns.Polya` distribution. p : float, :math:`0 < p < 1` - Success probability parameter of the :class:`~openturns.NegativeBinomial` + Success probability parameter of the :class:`~openturns.Polya` distribution. Notes @@ -36,7 +36,7 @@ and read: \end{array}, \quad 1 < i where :math:`r` and :math:`p` are the parameters of the -:class:`~openturns.NegativeBinomial` distribution. +:class:`~openturns.Polya` distribution. See also -------- @@ -57,12 +57,12 @@ Examples %feature("docstring") OT::MeixnerFactory::getP "Accessor to the success probability parameter :math:`p`. -Of the :class:`~openturns.NegativeBinomial` distribution. +Of the :class:`~openturns.Polya` distribution. Returns ------- p : float - Success probability parameter of the :class:`~openturns.NegativeBinomial` + Success probability parameter of the :class:`~openturns.Polya` distribution." // --------------------------------------------------------------------- @@ -70,10 +70,10 @@ p : float %feature("docstring") OT::MeixnerFactory::getR "Accessor to the number of failures parameter :math:`r`. -Of the :class:`~openturns.NegativeBinomial` distribution. +Of the :class:`~openturns.Polya` distribution. Returns ------- r : int - Number of failures parameter of the :class:`~openturns.NegativeBinomial` + Number of failures parameter of the :class:`~openturns.Polya` distribution." diff --git a/python/src/NegativeBinomial.i b/python/src/NegativeBinomial.i deleted file mode 100644 index 16f86fb62d..0000000000 --- a/python/src/NegativeBinomial.i +++ /dev/null @@ -1,11 +0,0 @@ -// SWIG file NegativeBinomial.i - -%{ -#include "openturns/NegativeBinomial.hxx" -%} - -%include NegativeBinomial_doc.i - -%copyctor OT::NegativeBinomial; - -%include openturns/NegativeBinomial.hxx diff --git a/python/src/NegativeBinomialFactory_doc.i.in b/python/src/NegativeBinomialFactory_doc.i.in index d645cc8eb4..4a7ced5db5 100644 --- a/python/src/NegativeBinomialFactory_doc.i.in +++ b/python/src/NegativeBinomialFactory_doc.i.in @@ -17,7 +17,7 @@ We use the following estimator: See also -------- -DistributionFactory, NegativeBinomial" +DistributionFactory, Polya" // --------------------------------------------------------------------- @@ -38,12 +38,12 @@ Parameters sample : 2-d sequence of float Data. param : sequence of float - The parameters of the :class:`~openturns.NegativeBinomial`. + The parameters of the :class:`~openturns.Polya`. Returns ------- -distribution : :class:`~openturns.NegativeBinomial` - The estimated distribution as a NegativeBinomial. +distribution : :class:`~openturns.Polya` + The estimated distribution as a Polya. - In the first usage, the default NegativeBinomial distribution is built." + In the first usage, the default Polya distribution is built." diff --git a/python/src/Polya.i b/python/src/Polya.i new file mode 100644 index 0000000000..39bf481ff0 --- /dev/null +++ b/python/src/Polya.i @@ -0,0 +1,11 @@ +// SWIG file Polya.i + +%{ +#include "openturns/Polya.hxx" +%} + +%include Polya_doc.i + +%copyctor OT::Polya; + +%include openturns/Polya.hxx diff --git a/python/src/NegativeBinomial_doc.i.in b/python/src/Polya_doc.i.in similarity index 83% rename from python/src/NegativeBinomial_doc.i.in rename to python/src/Polya_doc.i.in index 5540b8b8b5..01e297f264 100644 --- a/python/src/NegativeBinomial_doc.i.in +++ b/python/src/Polya_doc.i.in @@ -1,5 +1,5 @@ -%feature("docstring") OT::NegativeBinomial -"NegativeBinomial distribution. +%feature("docstring") OT::Polya +"Polya distribution. Parameters @@ -38,7 +38,7 @@ Examples Create a distribution: >>> import openturns as ot ->>> distribution = ot.NegativeBinomial(1.0, 0.6) +>>> distribution = ot.Polya(1.0, 0.6) Draw a sample: @@ -46,7 +46,7 @@ Draw a sample: // --------------------------------------------------------------------- -%feature("docstring") OT::NegativeBinomial::getP +%feature("docstring") OT::Polya::getP "Accessor to the success probability parameter. Returns @@ -56,7 +56,7 @@ p : float // --------------------------------------------------------------------- -%feature("docstring") OT::NegativeBinomial::getR +%feature("docstring") OT::Polya::getR "Accessor to the number of failures parameter. Returns @@ -66,7 +66,7 @@ r : float // --------------------------------------------------------------------- -%feature("docstring") OT::NegativeBinomial::setP +%feature("docstring") OT::Polya::setP "Accessor to the success probability parameter. Parameters @@ -76,7 +76,7 @@ p : float, :math:`0 \leq p \leq 1` // --------------------------------------------------------------------- -%feature("docstring") OT::NegativeBinomial::setR +%feature("docstring") OT::Polya::setR "Accessor to the number of failures parameter. Parameters diff --git a/python/src/StandardDistributionPolynomialFactory_doc.i.in b/python/src/StandardDistributionPolynomialFactory_doc.i.in index 3e06cd4144..f984a3c29c 100644 --- a/python/src/StandardDistributionPolynomialFactory_doc.i.in +++ b/python/src/StandardDistributionPolynomialFactory_doc.i.in @@ -57,7 +57,7 @@ distributions**. | :class:`~openturns.Binomial` | :class:`~openturns.KrawtchoukFactory` | | :math:`\cB(n, p)` | | +-----------------------------------------------------------------------+---------------------------------------+ - | :class:`~openturns.NegativeBinomial` | :class:`~openturns.MeixnerFactory` | + | :class:`~openturns.Polya` | :class:`~openturns.MeixnerFactory` | | :math:`\cB^-(r, p)` | | +-----------------------------------------------------------------------+---------------------------------------+ diff --git a/python/src/dist_bundle2_module.i b/python/src/dist_bundle2_module.i index 6a10df3fe4..c63aade6c9 100644 --- a/python/src/dist_bundle2_module.i +++ b/python/src/dist_bundle2_module.i @@ -61,7 +61,7 @@ %include DeconditionedDistribution.i %include Multinomial.i %include MultinomialFactory.i -%include NegativeBinomial.i +%include Polya.i %include NegativeBinomialFactory.i %include NonCentralChiSquare.i %include NonCentralStudent.i diff --git a/python/test/CMakeLists.txt b/python/test/CMakeLists.txt index 8cdfa477e9..cf910b9c1d 100644 --- a/python/test/CMakeLists.txt +++ b/python/test/CMakeLists.txt @@ -520,7 +520,7 @@ ot_pyinstallcheck_test (MixedHistogramUserDefined_std) ot_pyinstallcheck_test (Mixture_std) ot_pyinstallcheck_test (Multinomial_std) ot_pyinstallcheck_test (MultinomialFactory_std) -ot_pyinstallcheck_test (NegativeBinomial_std) +ot_pyinstallcheck_test (Polya_std) ot_pyinstallcheck_test (NegativeBinomialFactory_std) ot_pyinstallcheck_test (NonCentralChiSquare_std) if (Boost_FOUND) diff --git a/python/test/t_NegativeBinomialFactory_std.expout b/python/test/t_NegativeBinomialFactory_std.expout index 62def46903..6776cbfa0b 100644 --- a/python/test/t_NegativeBinomialFactory_std.expout +++ b/python/test/t_NegativeBinomialFactory_std.expout @@ -1,10 +1,10 @@ -distribution= class=NegativeBinomial name=NegativeBinomial dimension=1 r=15 p=0.7 -Estimated distribution= class=NegativeBinomial name=NegativeBinomial dimension=1 r=15.0803 p=0.699114 -Default distribution= class=NegativeBinomial name=NegativeBinomial dimension=1 r=1 p=0.5 -Distribution from parameters= class=NegativeBinomial name=NegativeBinomial dimension=1 r=15 p=0.7 -Default distribution= NegativeBinomial(r = 1, p = 0.5) -Distribution from parameters= NegativeBinomial(r = 15, p = 0.7) -NegativeBinomial = NegativeBinomial(r = 15, p = 0.7) -Estimated negativeBinomial= NegativeBinomial(r = 15.0803, p = 0.699114) -Default negativeBinomial= NegativeBinomial(r = 1, p = 0.5) -NegativeBinomial from parameters= NegativeBinomial(r = 15, p = 0.7) +distribution= class=Polya name=Polya dimension=1 r=15 p=0.7 +Estimated distribution= class=Polya name=Polya dimension=1 r=15.0803 p=0.699114 +Default distribution= class=Polya name=Polya dimension=1 r=1 p=0.5 +Distribution from parameters= class=Polya name=Polya dimension=1 r=15 p=0.7 +Default distribution= Polya(r = 1, p = 0.5) +Distribution from parameters= Polya(r = 15, p = 0.7) +Polya = Polya(r = 15, p = 0.7) +Estimated negativeBinomial= Polya(r = 15.0803, p = 0.699114) +Default negativeBinomial= Polya(r = 1, p = 0.5) +Polya from parameters= Polya(r = 15, p = 0.7) diff --git a/python/test/t_NegativeBinomialFactory_std.py b/python/test/t_NegativeBinomialFactory_std.py index e2ab60a4b8..fc45c1749b 100755 --- a/python/test/t_NegativeBinomialFactory_std.py +++ b/python/test/t_NegativeBinomialFactory_std.py @@ -4,7 +4,7 @@ ot.TESTPREAMBLE() -distribution = ot.NegativeBinomial(15, 0.7) +distribution = ot.Polya(15, 0.7) size = 10000 sample = distribution.getSample(size) factory = ot.NegativeBinomialFactory() @@ -20,9 +20,9 @@ estimatedDistribution = factory.build(distribution.getParameter()) print("Distribution from parameters=", estimatedDistribution) estimatedNegativeBinomial = factory.buildAsNegativeBinomial(sample) -print("NegativeBinomial =", distribution) +print("Polya =", distribution) print("Estimated negativeBinomial=", estimatedNegativeBinomial) estimatedNegativeBinomial = factory.buildAsNegativeBinomial() print("Default negativeBinomial=", estimatedNegativeBinomial) estimatedNegativeBinomial = factory.buildAsNegativeBinomial(distribution.getParameter()) -print("NegativeBinomial from parameters=", estimatedNegativeBinomial) +print("Polya from parameters=", estimatedNegativeBinomial) diff --git a/python/test/t_NegativeBinomial_std.expout b/python/test/t_Polya_std.expout similarity index 85% rename from python/test/t_NegativeBinomial_std.expout rename to python/test/t_Polya_std.expout index fa348aec46..8283d3da02 100644 --- a/python/test/t_NegativeBinomial_std.expout +++ b/python/test/t_Polya_std.expout @@ -1,5 +1,5 @@ -Distribution class=NegativeBinomial name=NegativeBinomial dimension=1 r=4.5 p=0.7 -Distribution NegativeBinomial(r = 4.5, p = 0.7) +Distribution class=Polya name=Polya dimension=1 r=4.5 p=0.7 +Distribution Polya(r = 4.5, p = 0.7) Elliptical = False Continuous = False oneRealization= class=Point name=Unnamed dimension=1 values=[7] @@ -19,4 +19,4 @@ skewness= class=Point name=Unnamed dimension=1 values=[0.957841] kurtosis= class=Point name=Unnamed dimension=1 values=[4.3619] covariance= class=CovarianceMatrix dimension=1 implementation=class=MatrixImplementation name=Unnamed rows=1 columns=1 values=[35] parameters= [class=PointWithDescription name=X0 dimension=2 description=[r,p] values=[4.5,0.7]] -Standard representative= NegativeBinomial(r = 4.5, p = 0.7) +Standard representative= Polya(r = 4.5, p = 0.7) diff --git a/python/test/t_NegativeBinomial_std.py b/python/test/t_Polya_std.py similarity index 97% rename from python/test/t_NegativeBinomial_std.py rename to python/test/t_Polya_std.py index 9996bf4c07..ed85d7c421 100755 --- a/python/test/t_NegativeBinomial_std.py +++ b/python/test/t_Polya_std.py @@ -5,7 +5,7 @@ ot.TESTPREAMBLE() # Instantiate one distribution object -distribution = ot.NegativeBinomial(4.5, 0.7) +distribution = ot.Polya(4.5, 0.7) print("Distribution ", repr(distribution)) print("Distribution ", distribution)