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 1978 by gezelter, Sun Jun 16 15:15:42 2013 UTC vs.
Revision 1979 by gezelter, Sat Apr 5 20:56:01 2014 UTC

# Line 163 | Line 163 | namespace OpenMD {
163        return;
164      }
165  
166 +    /**
167 +     * return the 95% confidence interval:
168 +     *
169 +     * That is returns c, such that we have 95% confidence that the
170 +     * true mean is within 2c of the Average (x):
171 +     *
172 +     *   x - c <= true mean <= x + c
173 +     *
174 +     */
175 +    void get95percentConfidenceInterval(ResultType &ret) {
176 +      assert(Count_ != 0);
177 +      RealType sd;
178 +      this->getStdDev(sd);
179 +      ret = 1.960 * sd / sqrt(Count_);
180 +      return;
181 +    }
182 +
183    private:
184      ElementType Val_;
185      ResultType Avg_;
# Line 256 | Line 273 | namespace OpenMD {
273        ret[0] = sqrt(var[0]);
274        ret[1] = sqrt(var[1]);
275        ret[2] = sqrt(var[2]);
276 +      return;
277 +    }
278 +
279 +    /**
280 +     * return the 95% confidence interval:
281 +     *
282 +     * That is returns c, such that we have 95% confidence that the
283 +     * true mean is within 2c of the Average (x):
284 +     *
285 +     *   x - c <= true mean <= x + c
286 +     *
287 +     */
288 +    void get95percentConfidenceInterval(ResultType &ret) {
289 +      assert(Count_ != 0);
290 +      ResultType sd;
291 +      this->getStdDev(sd);
292 +      ret[0] = 1.960 * sd[0] / sqrt(Count_);
293 +      ret[1] = 1.960 * sd[1] / sqrt(Count_);
294 +      ret[2] = 1.960 * sd[2] / sqrt(Count_);
295        return;
296      }
297  
# Line 306 | Line 342 | namespace OpenMD {
342        return;
343      }
344  
345 +    /**
346 +     * return the 95% confidence interval:
347 +     *
348 +     * That is returns c, such that we have 95% confidence that the
349 +     * true mean is within 2c of the Average (x):
350 +     *
351 +     *   x - c <= true mean <= x + c
352 +     *
353 +     */
354 +    void getLength95percentConfidenceInterval(ResultType &ret) {
355 +      assert(Count_ != 0);
356 +      RealType sd;
357 +      this->getLengthStdDev(sd);
358 +      ret = 1.960 * sd / sqrt(Count_);
359 +      return;
360 +    }
361 +
362 +
363    private:
364      ResultType Val_;
365      ResultType Avg_;
# Line 395 | Line 449 | namespace OpenMD {
449        }
450        return;
451      }
452 <        
452 >      
453 >    /**
454 >     * return the 95% confidence interval:
455 >     *
456 >     * That is returns c, such that we have 95% confidence that the
457 >     * true mean is within 2c of the Average (x):
458 >     *
459 >     *   x - c <= true mean <= x + c
460 >     *
461 >     */
462 >    void get95percentConfidenceInterval(ResultType &ret) {
463 >      assert(Count_ != 0);
464 >      Mat3x3d sd;
465 >      this->getStdDev(sd);
466 >      for (unsigned int i = 0; i < 3; i++) {
467 >        for (unsigned int j = 0; j < 3; j++) {
468 >          ret(i,j) = 1.960 * sd(i,j) / sqrt(Count_);
469 >        }
470 >      }
471 >      return;
472 >    }
473 >
474    private:
475      ElementType Val_;
476      ResultType Avg_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines