ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/utils/Accumulator.hpp
(Generate patch)

Comparing trunk/src/utils/Accumulator.hpp (file contents):
Revision 1879 by gezelter, Sun Jun 16 15:15:42 2013 UTC vs.
Revision 2071 by gezelter, Sat Mar 7 21:41:51 2015 UTC

# Line 59 | Line 59 | namespace OpenMD {
59      virtual size_t count()  {
60        return Count_;
61      }
62 +    virtual ~BaseAccumulator() {};
63    protected:
64      size_t Count_;
65  
# Line 79 | Line 80 | namespace OpenMD {
80      Accumulator() : BaseAccumulator() {
81        this->clear();
82      }
83 +    
84 +    ~Accumulator() {};
85  
86      /**
87       * Accumulate another value
# Line 160 | Line 163 | namespace OpenMD {
163      void getMin(ElementType &ret)  {
164        assert(Count_ != 0);
165        ret = Max_;
166 +      return;
167 +    }
168 +
169 +    /**
170 +     * return the 95% confidence interval:
171 +     *
172 +     * That is returns c, such that we have 95% confidence that the
173 +     * true mean is within 2c of the Average (x):
174 +     *
175 +     *   x - c <= true mean <= x + c
176 +     *
177 +     */
178 +    void get95percentConfidenceInterval(ResultType &ret) {
179 +      assert(Count_ != 0);
180 +      RealType sd;
181 +      this->getStdDev(sd);
182 +      ret = 1.960 * sd / sqrt(RealType(Count_));
183        return;
184      }
185  
# Line 260 | Line 280 | namespace OpenMD {
280      }
281  
282      /**
283 +     * return the 95% confidence interval:
284 +     *
285 +     * That is returns c, such that we have 95% confidence that the
286 +     * true mean is within 2c of the Average (x):
287 +     *
288 +     *   x - c <= true mean <= x + c
289 +     *
290 +     */
291 +    void get95percentConfidenceInterval(ResultType &ret) {
292 +      assert(Count_ != 0);
293 +      ResultType sd;
294 +      this->getStdDev(sd);
295 +      ret[0] = 1.960 * sd[0] / sqrt(RealType(Count_));
296 +      ret[1] = 1.960 * sd[1] / sqrt(RealType(Count_));
297 +      ret[2] = 1.960 * sd[2] / sqrt(RealType(Count_));
298 +      return;
299 +    }
300 +
301 +    /**
302       * return the largest length
303       */
304      void getMaxLength(RealType &ret) {
# Line 303 | Line 342 | namespace OpenMD {
342        RealType var;
343        this->getLengthVariance(var);
344        ret = sqrt(var);
345 +      return;
346 +    }
347 +
348 +    /**
349 +     * return the 95% confidence interval:
350 +     *
351 +     * That is returns c, such that we have 95% confidence that the
352 +     * true mean is within 2c of the Average (x):
353 +     *
354 +     *   x - c <= true mean <= x + c
355 +     *
356 +     */
357 +    void getLength95percentConfidenceInterval(ResultType &ret) {
358 +      assert(Count_ != 0);
359 +      RealType sd;
360 +      this->getLengthStdDev(sd);
361 +      ret = 1.960 * sd / sqrt(RealType(Count_));
362        return;
363      }
364  
365 +
366    private:
367      ResultType Val_;
368      ResultType Avg_;
# Line 395 | Line 452 | namespace OpenMD {
452        }
453        return;
454      }
455 <        
455 >      
456 >    /**
457 >     * return the 95% confidence interval:
458 >     *
459 >     * That is returns c, such that we have 95% confidence that the
460 >     * true mean is within 2c of the Average (x):
461 >     *
462 >     *   x - c <= true mean <= x + c
463 >     *
464 >     */
465 >    void get95percentConfidenceInterval(ResultType &ret) {
466 >      assert(Count_ != 0);
467 >      Mat3x3d sd;
468 >      this->getStdDev(sd);
469 >      for (unsigned int i = 0; i < 3; i++) {
470 >        for (unsigned int j = 0; j < 3; j++) {
471 >          ret(i,j) = 1.960 * sd(i,j) / sqrt(RealType(Count_));
472 >        }
473 >      }
474 >      return;
475 >    }
476 >
477    private:
478      ElementType Val_;
479      ResultType Avg_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines