www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
MonteCarloSampler Class Reference

A class used to perform Monte Carlo Sampling. More...

#include <MonteCarloSampler.h>

Inheritance diagram for MonteCarloSampler:
[legend]

Public Member Functions

 MonteCarloSampler (const InputParameters &parameters)
 

Protected Member Functions

virtual std::vector< DenseMatrix< Real > > sample () override
 

Protected Attributes

const std::size_t _num_samples
 Number of monte carlo samples to create for each distribution. More...
 

Detailed Description

A class used to perform Monte Carlo Sampling.

Definition at line 22 of file MonteCarloSampler.h.

Constructor & Destructor Documentation

◆ MonteCarloSampler()

MonteCarloSampler::MonteCarloSampler ( const InputParameters &  parameters)

Definition at line 25 of file MonteCarloSampler.C.

26  : Sampler(parameters), _num_samples(getParam<unsigned int>("n_samples"))
27 {
28 }
const std::size_t _num_samples
Number of monte carlo samples to create for each distribution.

Member Function Documentation

◆ sample()

std::vector< DenseMatrix< Real > > MonteCarloSampler::sample ( )
overrideprotectedvirtual

Definition at line 31 of file MonteCarloSampler.C.

32 {
33  std::vector<DenseMatrix<Real>> output(1);
34  output[0].resize(_num_samples, _distributions.size());
35  for (std::size_t i = 0; i < _num_samples; ++i)
36  for (auto j = beginIndex(_distributions); j < _distributions.size(); ++j)
37  output[0](i, j) = _distributions[j]->quantile(rand());
38  return output;
39 }
const std::size_t _num_samples
Number of monte carlo samples to create for each distribution.

Member Data Documentation

◆ _num_samples

const std::size_t MonteCarloSampler::_num_samples
protected

Number of monte carlo samples to create for each distribution.

Definition at line 31 of file MonteCarloSampler.h.

Referenced by sample().


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