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

« back to all changes in this revision

Viewing changes to lib/src/Uncertainty/Algorithm/Simulation/QuasiMonteCarloResult.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Fabrice Coutadeur
  • Date: 2010-05-10 17:27:55 UTC
  • mfrom: (1.1.4 upstream) (5.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100510172755-cb5ynskknqqi5rhp
Tags: 0.13.2-2ubuntu1
* Merge with Debian testing. No changes left.
* ubuntu_fix-python-2.6.patch: fix detection of python 2.6 libs, to not use
  LOCALMODLIBS. This pulls a dependency on SSL and makes the package FTBFS.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//                                               -*- C++ -*-
 
2
/**
 
3
 *  @file  QuasiMonteCarloResult.cxx
 
4
 *  @brief Implementation of SimulationResult
 
5
 *
 
6
 *  (C) Copyright 2005-2010 EDF-EADS-Phimeca
 
7
 *
 
8
 *  This library is free software; you can redistribute it and/or
 
9
 *  modify it under the terms of the GNU Lesser General Public
 
10
 *  License as published by the Free Software Foundation; either
 
11
 *  version 2.1 of the License.
 
12
 *
 
13
 *  This library is distributed in the hope that it will be useful
 
14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
 *  Lesser General Public License for more details.
 
17
 *
 
18
 *  You should have received a copy of the GNU Lesser General Public
 
19
 *  License along with this library; if not, write to the Free Software
 
20
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 
21
 *
 
22
 *  @author: $LastChangedBy: schueller $
 
23
 *  @date:   $LastChangedDate: 2008-05-23 13:46:12 +0200 (ven, 23 mai 2008) $
 
24
 *  Id:      $Id: QuasiMonteCarloResult.cxx 821 2008-05-23 11:46:12Z schueller $
 
25
 */
 
26
#include "QuasiMonteCarloResult.hxx"
 
27
#include "Log.hxx"
 
28
 
 
29
namespace OpenTURNS
 
30
{
 
31
  namespace Uncertainty
 
32
  {
 
33
 
 
34
    namespace Algorithm
 
35
    {
 
36
 
 
37
      CLASSNAMEINIT(QuasiMonteCarloResult);
 
38
 
 
39
      typedef Base::Common::Log Log;
 
40
 
 
41
      /* Default constructor */
 
42
      QuasiMonteCarloResult::QuasiMonteCarloResult()
 
43
        : SimulationResultImplementation()
 
44
      {
 
45
        // Nothing to do
 
46
      }
 
47
 
 
48
      /* Standard constructor */
 
49
      QuasiMonteCarloResult::QuasiMonteCarloResult(const NumericalScalar probabilityEstimate,
 
50
                                                   const NumericalScalar varianceEstimate,
 
51
                                                   const UnsignedLong outerSampling,
 
52
                                                   const UnsignedLong blockSize) throw(InvalidArgumentException)
 
53
        : SimulationResultImplementation(probabilityEstimate, varianceEstimate, outerSampling, blockSize)
 
54
      {
 
55
        // Check if the probability estimate is within the range [0, 1]
 
56
        if ((probabilityEstimate < 0) || (probabilityEstimate > 1)) Log::Info("The probability estimate should be in the range [0, 1]");
 
57
        // Check if the variance estimate is >= 0.0
 
58
        if (varianceEstimate < 0.0) throw InvalidArgumentException(HERE) << "The variance estimate must be >= 0";
 
59
      }
 
60
 
 
61
      /* Virtual constructor */
 
62
      QuasiMonteCarloResult * QuasiMonteCarloResult::clone() const
 
63
      {
 
64
        return new QuasiMonteCarloResult(*this);
 
65
      }
 
66
 
 
67
      /* Coefficient of variation estimate accessor */
 
68
      NumericalScalar QuasiMonteCarloResult::getCoefficientOfVariation() const
 
69
      {
 
70
        return -1.0;
 
71
      }
 
72
 
 
73
      /* String converter */
 
74
      String QuasiMonteCarloResult::__repr__() const
 
75
      {
 
76
        OSS oss;
 
77
        oss.setPrecision(6);
 
78
        oss << std::scientific
 
79
            << "probabilityEstimate=" << probabilityEstimate_
 
80
            << " varianceEstimate=" << varianceEstimate_
 
81
            << " outerSampling=" << outerSampling_
 
82
            << " blockSize=" << blockSize_;
 
83
 
 
84
        return oss;
 
85
      }
 
86
 
 
87
      /* Confidence length */
 
88
      NumericalScalar QuasiMonteCarloResult::getConfidenceLength(const NumericalScalar level) const
 
89
        throw(InvalidArgumentException)
 
90
      {
 
91
        throw NotYetImplementedException(HERE) << "cannot compute confidence interval for QMC sampling";
 
92
      }
 
93
 
 
94
 
 
95
 
 
96
    } /* namespace Algorithm */
 
97
  } /* namespace Uncertainty */
 
98
} /* namespace OpenTURNS */