Mantid
Loading...
Searching...
No Matches
MDDimensionStats.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
10
11namespace Mantid {
12namespace DataObjects {
13
20class MANTID_DATAOBJECTS_DLL MDDimensionStats {
21public:
23 MDDimensionStats() : total(0.0), totalApproxVariance(0.0), numPoints(0) {}
24
25 //---------------------------------------------------------------------------------------
27 coord_t getMean() const { return total / static_cast<coord_t>(numPoints); }
28
31 coord_t getApproxVariance() const { return totalApproxVariance / static_cast<coord_t>(numPoints); }
32
33 //---------------------------------------------------------------------------------------
37 void addPoint(const coord_t x) {
38 total += x;
39 numPoints++;
40 coord_t diff = (x - total / static_cast<coord_t>(numPoints));
41 totalApproxVariance += diff * diff;
42 }
43
44 //---------------------------------------------------------------------------------------
45 //--- Public members ---
46
50
60
62 size_t numPoints;
63};
64
65} // namespace DataObjects
66} // namespace Mantid
A simple class holding some statistics on the distribution of events in a particular dimension.
coord_t totalApproxVariance
Approximate variance - used for quick std.deviation estimates.
size_t numPoints
Number of points counted (used to give the mean).
void addPoint(const coord_t x)
Add a point with the given coordinate; track the mean and variance.
coord_t getMean() const
Returns the mean position of events in this dimension.
coord_t getApproxVariance() const
Returns the approximate standard deviation of the position of events in this dimension.
coord_t total
Total dimension (summed by each event).
Helper class which provides the Collimation Length for SANS instruments.
float coord_t
Typedef for the data type to use for coordinate axes in MD objects such as MDBox, MDEventWorkspace,...
Definition: MDTypes.h:27