https://mooseframework.inl.gov
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
StochasticTools::BootstrapCalculator< InType, OutType > Class Template Referenceabstract

Base class for computing bootstrap confidence level intervals. More...

#include <BootstrapCalculators.h>

Inheritance diagram for StochasticTools::BootstrapCalculator< InType, OutType >:
[legend]

Public Member Functions

 BootstrapCalculator (const libMesh::ParallelObject &other, const std::string &name, const std::vector< Real > &levels, unsigned int replicates, unsigned int seed, StochasticTools::Calculator< InType, OutType > &calc)
 
virtual std::vector< OutType > compute (const InType &, const bool)=0
 
const std::string & name () const
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Protected Member Functions

std::vector< OutType > computeBootstrapEstimates (const InType &, const bool)
 

Protected Attributes

const std::vector< Real_levels
 
const unsigned int _replicates
 
const unsigned int _seed
 
StochasticTools::Calculator< InType, OutType > & _calc
 
const Parallel::Communicator & _communicator
 

Private Attributes

const std::string _name
 

Detailed Description

template<typename InType, typename OutType>
class StochasticTools::BootstrapCalculator< InType, OutType >

Base class for computing bootstrap confidence level intervals.

These classes follow the same design pattern as those Statistics.h.

Parameters
otherParallelObject that is providing the Communicator
levelsThe bootstrap confidence level intervals to compute in range (0, 1)
replicatesNumber of bootstrap replicates to perform
seedSeed for random number generator

Definition at line 51 of file BootstrapCalculators.h.

Constructor & Destructor Documentation

◆ BootstrapCalculator()

template<typename InType, typename OutType>
StochasticTools::BootstrapCalculator< InType, OutType >::BootstrapCalculator ( const libMesh::ParallelObject other,
const std::string &  name,
const std::vector< Real > &  levels,
unsigned int  replicates,
unsigned int  seed,
StochasticTools::Calculator< InType, OutType > &  calc 
)

Definition at line 135 of file BootstrapCalculators.h.

142  : libMesh::ParallelObject(other),
143  _levels(levels),
144  _replicates(replicates),
145  _seed(seed),
146  _calc(calc),
147  _name(name)
148 {
149  mooseAssert(*std::min_element(levels.begin(), levels.end()) > 0,
150  "The supplied levels must be greater than zero.");
151  mooseAssert(*std::max_element(levels.begin(), levels.end()) < 1,
152  "The supplied levels must be less than one");
153 }
StochasticTools::Calculator< InType, OutType > & _calc

Member Function Documentation

◆ compute()

template<typename InType, typename OutType>
virtual std::vector<OutType> StochasticTools::BootstrapCalculator< InType, OutType >::compute ( const InType &  ,
const bool   
)
pure virtual

◆ computeBootstrapEstimates()

template<typename InType, typename OutType >
std::vector< OutType > StochasticTools::BootstrapCalculator< InType, OutType >::computeBootstrapEstimates ( const InType &  data,
const bool  is_distributed 
)
protected

Definition at line 157 of file BootstrapCalculators.h.

159 {
160  MooseRandom generator;
161  generator.seed(0, _seed);
162 
163  // Compute replicate statistics
164  std::vector<OutType> values(_replicates);
165  auto calc_update = [this](const typename InType::value_type & val)
166  { _calc.updateCalculator(val); };
167  for (std::size_t i = 0; i < _replicates; ++i)
168  {
169  _calc.initializeCalculator();
171  data, calc_update, generator, 0, is_distributed ? &this->_communicator : nullptr);
172  _calc.finalizeCalculator(is_distributed);
173  values[i] = _calc.getValue();
174  }
175  inplaceSort(values);
176  return values;
177 }
void seed(std::size_t i, unsigned int seed)
const Parallel::Communicator & _communicator
void resampleWithFunctor(const std::vector< T > &data, const ActionFunctor &functor, MooseRandom &generator, const std::size_t seed_index=0)
void inplaceSort(std::vector< T > &values)
StochasticTools::Calculator< InType, OutType > & _calc

◆ name()

template<typename InType, typename OutType>
const std::string& StochasticTools::BootstrapCalculator< InType, OutType >::name ( ) const
inline

Definition at line 61 of file BootstrapCalculators.h.

61 { return _name; }

Member Data Documentation

◆ _calc

template<typename InType, typename OutType>
StochasticTools::Calculator<InType, OutType>& StochasticTools::BootstrapCalculator< InType, OutType >::_calc
protected

Definition at line 77 of file BootstrapCalculators.h.

◆ _levels

template<typename InType, typename OutType>
const std::vector<Real> StochasticTools::BootstrapCalculator< InType, OutType >::_levels
protected

Definition at line 68 of file BootstrapCalculators.h.

◆ _name

template<typename InType, typename OutType>
const std::string StochasticTools::BootstrapCalculator< InType, OutType >::_name
private

◆ _replicates

template<typename InType, typename OutType>
const unsigned int StochasticTools::BootstrapCalculator< InType, OutType >::_replicates
protected

Definition at line 71 of file BootstrapCalculators.h.

◆ _seed

template<typename InType, typename OutType>
const unsigned int StochasticTools::BootstrapCalculator< InType, OutType >::_seed
protected

Definition at line 74 of file BootstrapCalculators.h.


The documentation for this class was generated from the following file: