Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://www.mooseframework.org 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : #include "LinearSum.h" 11 : 12 : registerMooseObject("StochasticToolsApp", LinearSum); 13 : 14 : InputParameters 15 0 : LinearSum::validParams() 16 : { 17 0 : InputParameters params = LikelihoodFunctionBase::validParams(); 18 0 : params.addClassDescription( 19 : "LinearSum function evaluating the model goodness against experiments."); 20 0 : return params; 21 0 : } 22 : 23 0 : LinearSum::LinearSum(const InputParameters & parameters) : Gaussian(parameters) {} 24 : 25 : Real 26 0 : LinearSum::function(const std::vector<Real> & exp, 27 : const std::vector<Real> & model, 28 : const Real & noise) 29 : { 30 : mooseAssert(exp.size() == model.size(), "LinearSum: Vectors must be the same size."); 31 : mooseAssert(noise != 0.0, "LinearSum: Noise must not be zero."); 32 : Real result = 0.0; 33 0 : for (unsigned int i = 0; i < exp.size(); ++i) 34 : { 35 0 : const Real diff = exp[i] - model[i]; 36 0 : result += diff * diff; 37 : } 38 0 : return result / (noise * noise); 39 : } 40 : 41 : Real 42 0 : LinearSum::function(const std::vector<Real> & x) const 43 : { 44 0 : return function(_exp_values, x, _noise); 45 : }