13#include "boost/multi_array.hpp"
38 return "Computes the most likely mean of the array by minimizing the taxicab "
39 "distance of the elements from the rest.";
46 auto lengthValidator = std::make_shared<ArrayLengthValidator<double>>();
47 lengthValidator->setLengthMin(1);
57 const std::vector<double> input =
getProperty(
"InputArray");
58 const auto size =
static_cast<int>(input.size());
59 boost::multi_array<double, 2> cov(boost::extents[size][size]);
61 for (
int i = 0; i < size; ++i) {
62 for (
int j = 0; j <= i; ++j) {
63 double diff = sqrt(
fabs(input[i] - input[j]));
68 std::vector<double> sums(size);
69 for (
int i = 0; i < size; ++i) {
70 sums[i] = std::accumulate(cov[i].begin(), cov[i].end(), 0.);
72 const auto minIndex = std::min_element(sums.cbegin(), sums.cend());
73 setProperty(
"Output", input[std::distance(sums.cbegin(), minIndex)]);
#define DECLARE_ALGORITHM(classname)
#define PARALLEL_FOR_NO_WSP_CHECK()
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
MostLikelyMean : Computes the most likely mean of the array by minimizing the taxicab distance of the...
void init() override
Initialize the algorithm's properties.
const std::string category() const override
Algorithm's category for identification.
void exec() override
Execute the algorithm.
const std::string summary() const override
Algorithm's summary for use in the GUI and help.
int version() const override
Algorithm's version for identification.
ArrayLenghtValidator : Validate length of an array property.
Support for a property that holds an array of values.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
The concrete, templated class for properties.
Describes the direction (within an algorithm) of a Property.
@ Input
An input workspace.
@ Output
An output workspace.