Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:27:59

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2019 CERN for the benefit of the Acts project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Utilities/Result.hpp"
0012 
0013 #include <sstream>
0014 #include <utility>
0015 #include <vector>
0016 
0017 namespace Acts {
0018 
0019 /// @class FsmwMode1dFinder
0020 
0021 /// Calculates the mode of a unidimenensional distribution
0022 /// using the Fraction of Sample Mode with Weights algorithm
0023 /// For reference, see:
0024 /// On a Fast, Robust Estimator of the Mode:
0025 /// Comparisons to Other Robust Estimators
0026 /// with Applications, David R. Bickel, Rudolf Fruehwirth, arXiv:math/0505419
0027 
0028 /// It's like an iterative "Half Sample Mode", but the fraction you take at each
0029 /// step can be configured by the user.
0030 
0031 /// Configuration possibilities:
0032 /// (1) fraction (default is 50 %)
0033 /// (2) firstFraction (default is 50 %)
0034 class FsmwMode1dFinder {
0035  public:
0036   /// Default constructor
0037   FsmwMode1dFinder() = default;
0038 
0039   /// Overload constructor
0040   ///
0041   /// @param firstFraction first fraction in FSMW algorithm
0042   /// @param fraction all other fractions in FSMW algorithm
0043   FsmwMode1dFinder(double firstFraction, double fraction);
0044 
0045   /// @brief Function to calculate mode with FSMW algorithm
0046   ///
0047   /// @param inputVector Input collection to calculate mode from
0048   ///
0049   /// @return mode value
0050   Result<double> getMode(
0051       std::vector<std::pair<double, double>> inputVector) const;
0052 
0053  private:
0054   double m_firstFraction = 0.5;
0055   double m_fraction = 0.5;
0056 };
0057 
0058 }  // namespace Acts