84 const Real mean_dist = 1993;
85 const Real std_dist = 27;
86 const std::size_t nsamp = 1000;
89 const unsigned int replicates = 1e4;
90 const std::vector<Real> levels = {0.05, 0.1, 0.2, 0.8, 0.9, 0.95};
93 Parallel::Communicator comm;
102 MooseEnum boot(
"percentile",
"percentile",
true);
108 const auto data = sampler.
sample(nsamp);
109 const Real mean_samp = mean_calc->compute(data,
false);
110 const Real std_samp = std_calc->compute(data,
false);
111 const std::vector<Real> mean_ci = mean_boot_calc->compute(data,
false);
112 const std::vector<Real> std_ci = std_boot_calc->compute(data,
false);
115 const Real
tol = 5e-1;
116 for (
const auto & l : index_range(levels))
119 const Real std_ref = sampler.
stdConfidence(levels[l], nsamp);
120 EXPECT_NEAR(mean_ci[l] - mean_samp, mean_ref, std::abs(mean_ref *
tol));
121 EXPECT_NEAR(std_ci[l] - std_samp, std_ref, std::abs(std_ref *
tol));
128 const Real mean_dist = 1993;
129 const Real std_dist = 27;
130 const std::size_t nsamp = 1000;
133 const unsigned int replicates = 1e4;
134 const std::vector<Real> levels = {0.05, 0.1, 0.2, 0.8, 0.9, 0.95};
137 Parallel::Communicator comm;
152 const auto data = sampler.
sample(nsamp);
153 const Real mean_samp = mean_calc->compute(data,
false);
154 const Real std_samp = std_calc->compute(data,
false);
155 const std::vector<Real> mean_ci = mean_boot_calc->compute(data,
false);
156 const std::vector<Real> std_ci = std_boot_calc->compute(data,
false);
159 const Real
tol = 5e-1;
160 for (
const auto & l : index_range(levels))
163 const Real std_ref = sampler.
stdConfidence(levels[l], nsamp);
164 EXPECT_NEAR(mean_ci[l] - mean_samp, mean_ref, std::abs(mean_ref *
tol));
165 EXPECT_NEAR(std_ci[l] - std_samp, std_ref, std::abs(std_ref *
tol));
169TEST(BootstrapCalculators, Percentile_Vec)
172 const std::size_t nsamp = 1000;
173 const std::size_t nval = 26;
174 std::vector<NormalSampler> samplers;
175 for (
const auto & k : make_range(nval))
176 samplers.emplace_back( 1993 + 42 * k, 27 + 7 * k, 1945);
179 const unsigned int replicates = 1e4;
180 const std::vector<Real> levels = {0.05, 0.1, 0.2, 0.8, 0.9, 0.95};
183 Parallel::Communicator comm;
188 auto mean_calc = makeCalculator<std::vector<std::vector<Real>>, std::vector<Real>>(calc[0], po);
189 auto std_calc = makeCalculator<std::vector<std::vector<Real>>, std::vector<Real>>(calc[1], po);
192 MooseEnum boot(
"percentile",
"percentile",
true);
193 auto mean_boot_calc = makeBootstrapCalculator<std::vector<std::vector<Real>>, std::vector<Real>>(
194 boot, po, levels, replicates, 2613, *mean_calc);
195 auto std_boot_calc = makeBootstrapCalculator<std::vector<std::vector<Real>>, std::vector<Real>>(
196 boot, po, levels, replicates, 2613, *std_calc);
199 std::vector<std::vector<Real>> data(nsamp);
200 for (
auto & dt : data)
201 for (
const auto & samp : samplers)
202 dt.push_back(samp.sample());
203 const std::vector<Real> mean_samp = mean_calc->compute(data,
false);
204 const std::vector<Real> std_samp = std_calc->compute(data,
false);
205 const std::vector<std::vector<Real>> mean_ci = mean_boot_calc->compute(data,
false);
206 const std::vector<std::vector<Real>> std_ci = std_boot_calc->compute(data,
false);
209 const Real
tol = 5e-1;
210 for (
const auto & l : index_range(levels))
211 for (
const auto & k : make_range(nval))
213 const Real mean_ref = samplers[k].meanConfidence(levels[l], nsamp);
214 const Real std_ref = samplers[k].stdConfidence(levels[l], nsamp);
215 EXPECT_NEAR(mean_ci[l][k] - mean_samp[k], mean_ref, std::abs(mean_ref *
tol));
216 EXPECT_NEAR(std_ci[l][k] - std_samp[k], std_ref, std::abs(std_ref *
tol));
220TEST(BootstrapCalculators, BiasCorrectedAccelerated_Vec)
223 const std::size_t nsamp = 1000;
224 const std::size_t nval = 26;
225 std::vector<NormalSampler> samplers;
226 for (
const auto & k : make_range(nval))
227 samplers.emplace_back( 1993 + 42 * k, 27 + 7 * k, 1945);
230 const unsigned int replicates = 1e4;
231 const std::vector<Real> levels = {0.05, 0.1, 0.2, 0.8, 0.9, 0.95};
234 Parallel::Communicator comm;
239 auto mean_calc = makeCalculator<std::vector<std::vector<Real>>, std::vector<Real>>(calc[0], po);
240 auto std_calc = makeCalculator<std::vector<std::vector<Real>>, std::vector<Real>>(calc[1], po);
244 auto mean_boot_calc = makeBootstrapCalculator<std::vector<std::vector<Real>>, std::vector<Real>>(
245 boot, po, levels, replicates, 2613, *mean_calc);
246 auto std_boot_calc = makeBootstrapCalculator<std::vector<std::vector<Real>>, std::vector<Real>>(
247 boot, po, levels, replicates, 2613, *std_calc);
250 std::vector<std::vector<Real>> data(nsamp);
251 for (
auto & dt : data)
252 for (
const auto & samp : samplers)
253 dt.push_back(samp.sample());
254 const std::vector<Real> mean_samp = mean_calc->compute(data,
false);
255 const std::vector<Real> std_samp = std_calc->compute(data,
false);
256 const std::vector<std::vector<Real>> mean_ci = mean_boot_calc->compute(data,
false);
257 const std::vector<std::vector<Real>> std_ci = std_boot_calc->compute(data,
false);
260 const Real
tol = 5e-1;
261 for (
const auto & l : index_range(levels))
262 for (
const auto & k : make_range(nval))
264 const Real mean_ref = samplers[k].meanConfidence(levels[l], nsamp);
265 const Real std_ref = samplers[k].stdConfidence(levels[l], nsamp);
266 EXPECT_NEAR(mean_ci[l][k] - mean_samp[k], mean_ref, std::abs(mean_ref *
tol));
267 EXPECT_NEAR(std_ci[l][k] - std_samp[k], std_ref, std::abs(std_ref *
tol));