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 20 of file MonteCarloSampler.h.

Constructor & Destructor Documentation

MonteCarloSampler::MonteCarloSampler ( const InputParameters &  parameters)

Definition at line 21 of file MonteCarloSampler.C.

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

Member Function Documentation

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

Definition at line 27 of file MonteCarloSampler.C.

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

Member Data Documentation

const std::size_t MonteCarloSampler::_num_samples
protected

Number of monte carlo samples to create for each distribution.

Definition at line 29 of file MonteCarloSampler.h.

Referenced by sample().


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