~ubuntu-branches/ubuntu/maverick/openturns/maverick

« back to all changes in this revision

Viewing changes to lib/src/Uncertainty/Distribution/Student.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Fabrice Coutadeur
  • Date: 2009-08-18 18:14:38 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090818181438-copqi92r4z7y0ejc
Tags: 0.13.1-1ubuntu1
debian/python-openturns.install: update to use python* and *-packages.
This fix a FTBFS with python2.6.  (LP: #350437)

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21
21
 *
22
22
 *  @author: $LastChangedBy: dutka $
23
 
 *  @date:   $LastChangedDate: 2009-02-10 15:42:19 +0100 (mar 10 fév 2009) $
24
 
 *  Id:      $Id: Student.cxx 1124 2009-02-10 14:42:19Z dutka $
 
23
 *  @date:   $LastChangedDate: 2009-05-28 14:47:53 +0200 (jeu. 28 mai 2009) $
 
24
 *  Id:      $Id: Student.cxx 1262 2009-05-28 12:47:53Z dutka $
25
25
 */
 
26
#include <cstdlib>
26
27
#include <cmath>
 
28
 
27
29
#include "Student.hxx"
28
30
#include "IdentityMatrix.hxx"
29
31
#include "RandomGenerator.hxx"
43
45
 
44
46
    namespace Distribution {
45
47
 
46
 
      const UnsignedLong Student::MaximumNumberOfPoints;
47
 
      const UnsignedLong Student::MinimumNumberOfPoints;
48
 
      const NumericalScalar Student::MaximumCDFEpsilon;
49
 
      const NumericalScalar Student::MinimumCDFEpsilon;
 
48
      CLASSNAMEINIT(Student);
 
49
 
 
50
      static Base::Common::Factory<Student> RegisteredFactory("Student");
50
51
 
51
52
      typedef Base::Type::IdentityMatrix               IdentityMatrix;
52
53
      typedef Base::Type::NumericalPointImplementation NumericalPointImplementation;
53
54
      typedef Base::Stat::RandomGenerator              RandomGenerator;
54
55
      typedef Base::Common::Log                        Log;
55
56
      typedef Base::Common::NotYetImplementedException NotYetImplementedException;
56
 
      CLASSNAMEINIT(Student);
 
57
      typedef Base::Common::ResourceMap                ResourceMap;
57
58
 
58
 
      static Base::Common::Factory<Student> RegisteredFactory("Student");
 
59
      const UnsignedLong Student::MaximumNumberOfPoints = 10000000;//strtoul(ResourceMap::GetInstance().get("SobolSequence-InitialSeed").c_str(), NULL, 0);
 
60
      const UnsignedLong Student::MinimumNumberOfPoints = 1000000;//strtoul(ResourceMap::GetInstance().get("SobolSequence-InitialSeed").c_str(), NULL, 0);
 
61
      const NumericalScalar Student::MaximumCDFEpsilon = 5.0e-6;//strtod(ResourceMap::GetInstance().get("SobolSequence-InitialSeed").c_str(), NULL);
 
62
      const NumericalScalar Student::MinimumCDFEpsilon = 5.0e-2;//strtod(ResourceMap::GetInstance().get("SobolSequence-InitialSeed").c_str(), NULL);
59
63
 
60
64
      /* Default constructor */
61
65
      Student::Student(const NumericalScalar nu,
111
115
      }
112
116
  
113
117
      /* String converter */
114
 
      String Student::str() const
 
118
      String Student::__repr__() const
115
119
      {
116
120
        OSS oss;
117
121
        oss << "class=" << Student::GetClassName()
200
204
        // For the bidimensional case, use specialized high precision routine
201
205
        if (dimension == 2)
202
206
          {
203
 
            int nu(round(nu_));
 
207
            int nu(static_cast<int>(round(nu_)));
204
208
            double r(R_(0, 1));
205
209
            return BVTL_F77(&nu, &(u[0]), &(u[1]), &r);
206
210
          }
207
211
        // For the tridimensional case, use specialized high precision routine
208
212
        if (dimension == 3)
209
213
          {
210
 
            int nu(round(nu_));
 
214
            int nu(static_cast<int>(round(nu_)));
211
215
            double r[3];
212
216
            r[0] = R_(1, 0);
213
217
            r[1] = R_(2, 0);
219
223
        // For larger dimension, use an adaptive integration
220
224
        if (dimension <= 500)
221
225
          {
222
 
            int nu(round(nu_));
 
226
            int nu(static_cast<int>(round(nu_)));
223
227
            NumericalPoint lower(dimension, 0.0);
224
228
            std::vector<int> infin(dimension, 0);
225
229
            NumericalPoint correl(dimension * (dimension - 1) / 2, 0.0);
241
245
            double error;
242
246
            double value;
243
247
            int inform;
244
 
            int dim = static_cast<UnsignedLong>( dimension );
 
248
            int dim(static_cast<UnsignedLong>( dimension ));
245
249
            do
246
250
              {
247
251
                MVTDST_F77(&dim, &nu, &lower[0], &u[0], &infin[0], &correl[0], &delta[0], &maxpts, &abseps, &releps, &error, &value, &inform);
310
314
        // For large dimension, use an adaptive integration
311
315
        if (dimension <= 500)
312
316
          {
313
 
            int nu(round(nu_));
 
317
            int nu(static_cast<UnsignedLong>(round(nu_)));
314
318
            // Build finite/infinite flags according to MVNDST documentation
315
319
            std::vector<int> infin(dimension, -1);
316
320
            for (UnsignedLong i = 0; i < dimension; i++)
635
639
      }
636
640
 
637
641
      /* Quantile computation for dimension=1 */
638
 
      NumericalScalar Student::computeScalarQuantile(const NumericalScalar p,
 
642
      NumericalScalar Student::computeScalarQuantile(const NumericalScalar prob,
639
643
                                                     const NumericalScalar initialGuess,
640
 
                                                     const NumericalScalar initialStep) const
 
644
                                                     const NumericalScalar initialStep,
 
645
                                                     const NumericalScalar precision) const
641
646
      {
642
 
        if (p < 0.0 || p > 1.0) throw InvalidArgumentException(HERE) << "Error: cannot compute a quantile for a probability level outside of ]0, 1[";
643
 
        if (p == 0.0) return -0.5 * sqrt(4.0 * (log(SpecFunc::ISQRT2PI) - SpecFunc::LogMinNumericalScalar));
644
 
        if (p == 1.0) return 0.5 * sqrt(4.0 * (log(SpecFunc::ISQRT2PI) - SpecFunc::LogMinNumericalScalar));
645
 
        return DistFunc::qStudent(nu_, p);
 
647
        return DistFunc::qStudent(nu_, prob);
646
648
      }
647
649
 
648
650
      /* Method save() stores the object through the StorageManager */