Mantid
Loading...
Searching...
No Matches
BivariateNormal.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2011 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
15
16namespace Mantid {
17namespace HistogramData {
18class HistogramY;
19}
20namespace CurveFitting {
21namespace Functions {
22
71class MANTID_CURVEFITTING_DLL BivariateNormal : public API::ParamFunction,
72 public API::IFunction1D,
73 public API::IFunctionMW {
74public:
77 ~BivariateNormal() override;
78
80 std::string name() const override { return "BivariateNormal"; }
81
82 const std::string category() const override { return "Peak"; }
83
84 void function1D(double *out, const double *xValues, const size_t nData) const override;
85
86 void functionDeriv1D(API::Jacobian *out, const double *xValues, const size_t nData) override;
87
88 size_t nAttributes() const override { return (size_t)1; }
89
90 std::vector<std::string> getAttributeNames() const override {
91 std::vector<std::string> V;
92 V.emplace_back("CalcVariances");
93 return V;
94 }
95
96 Attribute getAttribute(const std::string &attName) const override {
97 if (!hasAttribute(attName))
98 throw std::invalid_argument("Not a valid attribute name");
99
100 // if( CalcVariances)
101 // return Attribute( 1);
102
103 return Attribute(CalcVariances);
104 }
105
106 void setAttribute(const std::string &attName, const Attribute &value) override {
107
108 if (!hasAttribute(attName))
109 throw std::invalid_argument("Not a valid attribute name");
110
111 CalcVariances = value.asBool();
112
113 if (CalcVariances) {
114 CalcVxx = CalcVyy = CalcVxy = true;
115 } else {
116 declareParameter("SScol", 0.00, "Variance of the column(x) values");
117 declareParameter("SSrow", 0.00, "Variance of the row(y) values");
118 declareParameter("SSrc", 0.00, "Covariance of the column(x) and row(y) values");
119 CalcVxx = CalcVyy = CalcVxy = false;
120 }
121 }
122
123 bool hasAttribute(const std::string &attName) const override { return attName == "CalcVariances"; }
124
125 bool CalcVxx, CalcVyy, CalcVxy;
126
127protected:
128 void init() override;
129
131
133
134 double initCommon();
136
137 // Returns penalty.
138 double initCoeff(const HistogramData::HistogramY &D, const HistogramData::HistogramY &X,
139 const HistogramData::HistogramY &Y, double &coefNorm, double &expCoeffx2, double &expCoeffy2,
140 double &expCoeffxy, int &NCells, double &Varxx, double &Varxy, double &Varyy) const;
141
142 double mIx, mx, mIy, my; //< For calculating variances
143 double SIxx, SIyy, SIxy, Sxx, Syy, Sxy; //< For calculating variances
144 double TotI, TotN; //< For calculating variances
145
146 double Varx0, Vary0; // Crude estimate of the variances for bounds on
147 // variances
148
149 double LastParams[9];
150
151 double *expVals;
152
153 double uu, coefNorm, expCoeffx2, expCoeffy2,
154 expCoeffxy; //<Other common values used in calculating values and
155 //<derivatives
156};
157} // namespace Functions
158} // namespace CurveFitting
159} // namespace Mantid
double value
The value of the point.
Definition: FitMW.cpp:51
Mantid::API::IFunction::Attribute Attribute
Definition: IsoRotDiff.cpp:25
This is a specialization of IFunction for functions of one real argument.
Definition: IFunction1D.h:43
This is a specialization of IFunction for functions defined on a MatrixWorkspace.
Definition: IFunctionMW.h:30
Attribute is a non-fitting parameter.
Definition: IFunction.h:282
Represents the Jacobian in IFitFunction::functionDeriv.
Definition: Jacobian.h:22
Implements the part of IFunction interface dealing with parameters.
Definition: ParamFunction.h:33
Provide peak shape function interface a Peak shape on one time slice of a RectangularDetector.
bool CalcVariances
from experimental data versus fit the (Co)Variances
bool hasAttribute(const std::string &attName) const override
Check if attribute attName exists.
double * expVals
Save common exponential values for each cell.
void setAttribute(const std::string &attName, const Attribute &value) override
Set a value to attribute attName.
size_t nAttributes() const override
Returns the number of attributes associated with the function.
const std::string category() const override
The categories the Fit function belong to.
std::vector< std::string > getAttributeNames() const override
Returns a list of attribute names.
std::string name() const override
overwrite IFunction base class methods
Attribute getAttribute(const std::string &attName) const override
Return a value of attribute attName.
Helper class which provides the Collimation Length for SANS instruments.