LCOV - code coverage report
Current view: top level - src/samplers - MonteCarloSampler.C (source / functions) Hit Total Coverage
Test: stochastic_tools Test Coverage Lines: 17 17 100.0 %
Date: 2017-11-20 14:55:45 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /****************************************************************/
       2             : /* MOOSE - Multiphysics Object Oriented Simulation Environment  */
       3             : /*                                                              */
       4             : /*          All contents are licensed under LGPL V2.1           */
       5             : /*             See LICENSE for full restrictions                */
       6             : /****************************************************************/
       7             : 
       8             : #include "MonteCarloSampler.h"
       9             : 
      10             : template <>
      11             : InputParameters
      12          15 : validParams<MonteCarloSampler>()
      13             : {
      14          15 :   InputParameters params = validParams<Sampler>();
      15          30 :   params.addClassDescription("Monte Carlo Sampler.");
      16          45 :   params.addRequiredParam<unsigned int>(
      17          15 :       "n_samples", "Number of Monte Carlo samples to perform for each distribution.");
      18          15 :   return params;
      19             : }
      20             : 
      21          16 : MonteCarloSampler::MonteCarloSampler(const InputParameters & parameters)
      22          48 :   : Sampler(parameters), _num_samples(getParam<unsigned int>("n_samples"))
      23             : {
      24          16 : }
      25             : 
      26             : std::vector<DenseMatrix<Real>>
      27          40 : MonteCarloSampler::sample()
      28             : {
      29          40 :   std::vector<DenseMatrix<Real>> output(1);
      30          40 :   output[0].resize(_num_samples, _distributions.size());
      31         590 :   for (std::size_t i = 0; i < _num_samples; ++i)
      32        1065 :     for (auto j = beginIndex(_distributions); j < _distributions.size(); ++j)
      33         790 :       output[0](i, j) = _distributions[j]->quantile(rand());
      34          40 :   return output;
      35        1812 : }

Generated by: LCOV version 1.11