Mantid
Loading...
Searching...
No Matches
Statistics.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2010 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
9#include "MantidKernel/DllConfig.h"
10#include <span>
11#include <vector>
12
13namespace Mantid {
14namespace Kernel {
15namespace Math {
30} // namespace Math
31
36struct MANTID_KERNEL_DLL Statistics {
38 double minimum;
40 double maximum;
42 double mean;
44 double median;
47
49 Statistics();
50};
51
54 enum Flag {
55 SortedData = 1, // is the data sorted?
56 Mean = 2, // calculate the mean
57 UncorrectedStdDev = 4, // calculate the s.d. using N dofs
58 CorrectedStdDev = 8, // calculate the s.d. using N-1 dofs
59 Median = 16, // calculate the median
61 };
62};
63
66struct Rfactor {
68 double Rwp;
70 double Rp;
72 Rfactor(double rwp, double rp) : Rwp(rwp), Rp(rp) {}
74 Rwp = -1.0;
75 Rp = -1.0;
76 }
77};
78
80template <typename TYPE>
81Statistics getStatistics(const std::vector<TYPE> &data, const unsigned int flags = StatOptions::AllStats);
83template <typename TYPE> std::vector<double> getZscore(const std::vector<TYPE> &data);
84
88MANTID_KERNEL_DLL Statistics getStatistics(std::span<double const> data,
89 const unsigned int flags = StatOptions::AllStats);
90MANTID_KERNEL_DLL std::vector<double> getZscore(std::span<double const> data);
91
92template <typename TYPE>
93std::vector<double> getWeightedZscore(const std::vector<TYPE> &data, const std::vector<TYPE> &weights);
95template <typename TYPE> std::vector<double> getModifiedZscore(const std::vector<TYPE> &data);
97Rfactor MANTID_KERNEL_DLL getRFactor(std::span<double const> obsI, std::span<double const> calI,
98 std::span<double const> obsE);
99
101template <typename TYPE>
102std::vector<double> getMomentsAboutOrigin(const std::vector<TYPE> &x, const std::vector<TYPE> &y,
103 const int maxMoment = 3);
105template <typename TYPE>
106std::vector<double> getMomentsAboutMean(const std::vector<TYPE> &x, const std::vector<TYPE> &y,
107 const int maxMoment = 3);
108} // namespace Kernel
109} // namespace Mantid
StatisticType
Maps a "statistic" to a number.
Definition Statistics.h:19
std::vector< double > getModifiedZscore(const std::vector< TYPE > &data)
Return the modified Z score values for a dataset.
Statistics getStatistics(const std::vector< TYPE > &data, const unsigned int flags=StatOptions::AllStats)
Return a statistics object for the given data set.
std::vector< double > getZscore(const std::vector< TYPE > &data)
Return the Z score values for a dataset.
Rfactor MANTID_KERNEL_DLL getRFactor(std::span< double const > obsI, std::span< double const > calI, std::span< double const > obsE)
Return the R-factors (Rwp) of a diffraction pattern data.
std::vector< double > getMomentsAboutMean(const std::vector< TYPE > &x, const std::vector< TYPE > &y, const int maxMoment=3)
Return the first n-moments of the supplied data.
std::vector< double > getWeightedZscore(const std::vector< TYPE > &data, const std::vector< TYPE > &weights)
There are enough special cases in determining the Z score where it useful to put it in a single funct...
std::vector< double > getMomentsAboutOrigin(const std::vector< TYPE > &x, const std::vector< TYPE > &y, const int maxMoment=3)
Return the first n-moments of the supplied data.
Helper class which provides the Collimation Length for SANS instruments.
R factor for powder data analysis.
Definition Statistics.h:66
Rfactor(double rwp, double rp)
Foos(int a, int b) : a(a), b(b) {}.
Definition Statistics.h:72
Controls the computation of statisical data.
Definition Statistics.h:53
Simple struct to store statistics.
Definition Statistics.h:36
double mean
Mean value.
Definition Statistics.h:42
double median
Median value.
Definition Statistics.h:44
double minimum
Minimum value.
Definition Statistics.h:38
double maximum
Maximum value.
Definition Statistics.h:40
double standard_deviation
standard_deviation of the values
Definition Statistics.h:46