23 template <
typename InType,
typename OutType>
28 const std::vector<OutType> values = this->computeBootstrapEstimates(data, is_distributed);
31 std::vector<OutType> output;
32 if (this->processor_id() == 0)
33 for (
const Real & level : this->_levels)
35 long unsigned int index = std::lrint(level * (this->_replicates - 1));
36 output.push_back(values[index]);
43 template <
typename InType,
typename OutType>
48 const std::vector<OutType> values = this->computeBootstrapEstimates(data, is_distributed);
51 const OutType
value = this->_calc.compute(data, is_distributed);
52 const Real count = std::count_if(
59 const OutType acc = data.empty() ? OutType() :
acceleration(data, is_distributed);
62 std::vector<OutType> output;
63 for (
const Real & level : this->_levels)
66 const Real x = bias + (bias + (bias + z) / (1 - acc * (bias + z)));
69 long unsigned int index = std::lrint(
alpha * (this->_replicates - 1));
70 output.push_back(values[index]);
75 template <
typename InType,
typename OutType>
78 const bool is_distributed)
80 const std::size_t local_size = data.size();
81 std::vector<std::size_t> local_sizes = {local_size};
83 this->_communicator.allgather(local_sizes);
84 const std::size_t count = std::accumulate(local_sizes.begin(), local_sizes.end(), 0);
88 std::vector<OutType> theta_i(local_size);
92 for (std::size_t i = 0; i < local_sizes[r]; ++i)
94 this->_calc.initializeCalculator();
95 for (std::size_t il = 0; il < local_size; ++il)
96 if (i != il || r != rank)
97 this->_calc.updateCalculator(data[il]);
98 this->_calc.finalizeCalculator(is_distributed);
100 theta_i[i] = this->_calc.getValue();
104 OutType theta_dot = std::accumulate(theta_i.begin(), theta_i.end(), OutType());
106 this->_communicator.sum(theta_dot);
110 std::vector<OutType> num_den(2);
111 for (
const auto & jk : theta_i)
117 this->_communicator.sum(num_den);
119 mooseAssert(num_den[1] != OutType(),
"The acceleration denomenator must not be zero.");
120 return num_den[0] / (6 *
std::pow(num_den[1], 3. / 2.));
123 template <
typename InType,
typename OutType>
124 std::unique_ptr<BootstrapCalculator<InType, OutType>>
128 const std::vector<Real> & levels,
129 unsigned int replicates,
133 std::unique_ptr<BootstrapCalculator<InType, OutType>> ptr =
nullptr;
134 if (item ==
"percentile")
136 std::make_unique<Percentile<InType, OutType>>(other, item, levels, replicates, seed, calc);
137 else if (item ==
"bca")
138 ptr = std::make_unique<BiasCorrectedAccelerated<InType, OutType>>(
139 other, item, levels, replicates, seed, calc);
142 ::mooseError(
"Failed to create Statistics::BootstrapCalculator object for ", item);
147 #define createBootstrapCalculators(InType, OutType) \ 148 template class Percentile<InType, OutType>; \ 149 template class BiasCorrectedAccelerated<InType, OutType>; \ 150 template struct BootstrapCalculatorBuilder<InType, OutType> static const std::string acceleration
virtual Real cdf(const Real &x) const override
uint8_t processor_id_type
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
const std::vector< double > x
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string v
static const std::string alpha
virtual Real quantile(const Real &p) const override
MooseUnits pow(const MooseUnits &, int)