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 <vector>
11
12namespace Mantid {
13namespace Kernel {
14namespace Math {
29} // namespace Math
30
35struct MANTID_KERNEL_DLL Statistics {
37 double minimum;
39 double maximum;
41 double mean;
43 double median;
46
48 Statistics();
49};
50
53 enum Flag {
54 SortedData = 1, // is the data sorted?
55 Mean = 2, // calculate the mean
56 UncorrectedStdDev = 4, // calculate the s.d. using N dofs
57 CorrectedStdDev = 8, // calculate the s.d. using N-1 dofs
58 Median = 16, // calculate the median
60 };
61};
62
65struct Rfactor {
67 double Rwp;
69 double Rp;
71 Rfactor(double rwp, double rp) : Rwp(rwp), Rp(rp) {}
73 Rwp = -1.0;
74 Rp = -1.0;
75 }
76};
77
79template <typename TYPE>
80Statistics getStatistics(const std::vector<TYPE> &data, const unsigned int flags = StatOptions::AllStats);
82template <typename TYPE> std::vector<double> getZscore(const std::vector<TYPE> &data);
83template <typename TYPE>
84std::vector<double> getWeightedZscore(const std::vector<TYPE> &data, const std::vector<TYPE> &weights);
86template <typename TYPE> std::vector<double> getModifiedZscore(const std::vector<TYPE> &data);
88Rfactor MANTID_KERNEL_DLL getRFactor(const std::vector<double> &obsI, const std::vector<double> &calI,
89 const std::vector<double> &obsE);
90
92template <typename TYPE>
93std::vector<double> getMomentsAboutOrigin(const std::vector<TYPE> &x, const std::vector<TYPE> &y,
94 const int maxMoment = 3);
96template <typename TYPE>
97std::vector<double> getMomentsAboutMean(const std::vector<TYPE> &x, const std::vector<TYPE> &y,
98 const int maxMoment = 3);
99} // namespace Kernel
100} // namespace Mantid
StatisticType
Maps a "statistic" to a number.
Definition Statistics.h:18
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.
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.
Rfactor MANTID_KERNEL_DLL getRFactor(const std::vector< double > &obsI, const std::vector< double > &calI, const std::vector< double > &obsE)
Return the R-factors (Rwp) of a diffraction pattern data.
Helper class which provides the Collimation Length for SANS instruments.
R factor for powder data analysis.
Definition Statistics.h:65
Rfactor(double rwp, double rp)
Foos(int a, int b) : a(a), b(b) {}.
Definition Statistics.h:71
Controls the computation of statisical data.
Definition Statistics.h:52
Simple struct to store statistics.
Definition Statistics.h:35
double mean
Mean value.
Definition Statistics.h:41
double median
Median value.
Definition Statistics.h:43
double minimum
Minimum value.
Definition Statistics.h:37
double maximum
Maximum value.
Definition Statistics.h:39
double standard_deviation
standard_deviation of the values
Definition Statistics.h:45