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 52 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 136 of file BootstrapCalculators.h.

143  : libMesh::ParallelObject(other),
144  _levels(levels),
145  _replicates(replicates),
146  _seed(seed),
147  _calc(calc),
148  _name(name)
149 {
150  mooseAssert(*std::min_element(levels.begin(), levels.end()) > 0,
151  "The supplied levels must be greater than zero.");
152  mooseAssert(*std::max_element(levels.begin(), levels.end()) < 1,
153  "The supplied levels must be less than one");
154 }
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 158 of file BootstrapCalculators.h.

160 {
161  MooseRandom generator;
162  generator.seed(0, _seed);
163 
164  // Compute replicate statistics
165  std::vector<OutType> values(_replicates);
166  auto calc_update = [this](const typename InType::value_type & val)
167  { _calc.updateCalculator(val); };
168  for (std::size_t i = 0; i < _replicates; ++i)
169  {
170  _calc.initializeCalculator();
172  data, calc_update, generator, 0, is_distributed ? &this->_communicator : nullptr);
173  _calc.finalizeCalculator(is_distributed);
174  values[i] = _calc.getValue();
175  }
176  inplaceSort(values);
177  return values;
178 }
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 62 of file BootstrapCalculators.h.

62 { return _name; }

Member Data Documentation

◆ _calc

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

Definition at line 78 of file BootstrapCalculators.h.

◆ _levels

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

Definition at line 69 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 72 of file BootstrapCalculators.h.

◆ _seed

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

Definition at line 75 of file BootstrapCalculators.h.


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