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

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

#include <SobolSampler.h>

Inheritance diagram for SobolSampler:
[legend]

Public Member Functions

 SobolSampler (const InputParameters &parameters)
 

Protected Member Functions

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

Protected Attributes

const std::size_t _num_samples
 Number of Monte Carlo samples to create for each Sobol matrix. More...
 
DenseMatrix< Real > _a_matrix
 
DenseMatrix< Real > _b_matrix
 

Detailed Description

A class used to perform Monte Carlo Sampling.

Definition at line 20 of file SobolSampler.h.

Constructor & Destructor Documentation

SobolSampler::SobolSampler ( const InputParameters &  parameters)

Definition at line 21 of file SobolSampler.C.

22  : Sampler(parameters),
23  _num_samples(getParam<unsigned int>("n_samples")),
24  _a_matrix(0, 0),
25  _b_matrix(0, 0)
26 {
27  setNumberOfRequiedRandomSeeds(2);
28 }
DenseMatrix< Real > _b_matrix
Definition: SobolSampler.h:36
DenseMatrix< Real > _a_matrix
Definition: SobolSampler.h:35
const std::size_t _num_samples
Number of Monte Carlo samples to create for each Sobol matrix.
Definition: SobolSampler.h:31

Member Function Documentation

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

Definition at line 51 of file SobolSampler.C.

52 {
53  // Create the output vector
54  auto n = _distributions.size() + 2;
55  std::vector<DenseMatrix<Real>> output(n);
56 
57  // Include the A and B matrices
58  output[0] = _a_matrix;
59  output[1] = _b_matrix;
60 
61  // Create the AB matrices
62  for (auto idx = beginIndex(_distributions, 2); idx < n; ++idx)
63  {
64  output[idx] = _a_matrix;
65  for (std::size_t i = 0; i < _num_samples; ++i)
66  output[idx](i, idx - 2) = _b_matrix(i, idx - 2);
67  }
68 
69  return output;
70 }
DenseMatrix< Real > _b_matrix
Definition: SobolSampler.h:36
DenseMatrix< Real > _a_matrix
Definition: SobolSampler.h:35
const std::size_t _num_samples
Number of Monte Carlo samples to create for each Sobol matrix.
Definition: SobolSampler.h:31
void SobolSampler::sampleSetUp ( )
overrideprotectedvirtual

Definition at line 31 of file SobolSampler.C.

32 {
33  _a_matrix.resize(_num_samples, _distributions.size());
34  _b_matrix.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  {
38  _a_matrix(i, j) = _distributions[j]->quantile(this->rand(0));
39  _b_matrix(i, j) = _distributions[j]->quantile(this->rand(1));
40  }
41 }
DenseMatrix< Real > _b_matrix
Definition: SobolSampler.h:36
DenseMatrix< Real > _a_matrix
Definition: SobolSampler.h:35
const std::size_t _num_samples
Number of Monte Carlo samples to create for each Sobol matrix.
Definition: SobolSampler.h:31
void SobolSampler::sampleTearDown ( )
overrideprotectedvirtual

Definition at line 44 of file SobolSampler.C.

45 {
46  _a_matrix.resize(0, 0);
47  _b_matrix.resize(0, 0);
48 }
DenseMatrix< Real > _b_matrix
Definition: SobolSampler.h:36
DenseMatrix< Real > _a_matrix
Definition: SobolSampler.h:35

Member Data Documentation

DenseMatrix<Real> SobolSampler::_a_matrix
protected

Sobol Monte Carlo matrices, these are sized and cleared to avoid keeping large matrices around

Definition at line 35 of file SobolSampler.h.

Referenced by sample(), sampleSetUp(), and sampleTearDown().

DenseMatrix<Real> SobolSampler::_b_matrix
protected

Definition at line 36 of file SobolSampler.h.

Referenced by sample(), sampleSetUp(), and sampleTearDown().

const std::size_t SobolSampler::_num_samples
protected

Number of Monte Carlo samples to create for each Sobol matrix.

Definition at line 31 of file SobolSampler.h.

Referenced by sample(), and sampleSetUp().


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