KerMor  0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
WeightedRandomSampler.m
Go to the documentation of this file.
1 namespace sampling{
2 
3 
4 /* (Autoinserted by mtoc++)
5  * This source code has been filtered by the mtoc++ executable,
6  * which generates code that can be processed by the doxygen documentation tool.
7  *
8  * On the other hand, it can neither be interpreted by MATLAB, nor can it be compiled with a C++ compiler.
9  * Except for the comments, the function bodies of your M-file functions are untouched.
10  * Consequently, the FILTER_SOURCE_FILES doxygen switch (default in our Doxyfile.template) will produce
11  * attached source files that are highly readable by humans.
12  *
13  * Additionally, links in the doxygen generated documentation to the source code of functions and class members refer to
14  * the correct locations in the source code browser.
15  * However, the line numbers most likely do not correspond to the line numbers in the original MATLAB source files.
16  */
17 
19  :public sampling.RandomSampler {
41  public:
42 
43 
44  function samples = performSampling(params) {
45 
46  nparams = length(params);
47 
48  /* Compute rescaling factor for each Desired entry to end up with
49  * prod(<ranges>) = model.sampling.samples */
50  rescaler = (this.Samples/prod([params(:).Desired]))^(1/nparams);
51 
52  ranges = cell(nparams,1);
53 
54  /* % Compute param ranges */
55  for pidx=1:nparams
56  p = params(pidx);
57  num = round(p.Desired * rescaler);
58  ranges[pidx] = sort(rand(1,num) * (p.MaxVal-p.MinVal) + p.MinVal);
59  end
60  /* No combinations necessary if only one parameter */
61  if nparams == 1
62  samples = ranges[pidx];
63  else
64  samples = Utils.createCombinations(ranges);
65  end
66  }
81 };
82 }
83 
84 
85 
Collection of generally useful functions.
Definition: Utils.m:17
WeightedRandomSampler: Computes random samples using the Desired fields of the parameters.
static function comb = createCombinations(ranges, varargin)
Creates the cartesian product of the vectors passed as a matrix containing elements of each vector pe...
Definition: Utils.m:114
A MatLab cell array or matrix.
sort
ort the handle objects in any array in ascending or descending order.
Samples
The number of samples to take.
Definition: RandomSampler.m:36
RandomSampler Selects Samples many random parameters.
Definition: RandomSampler.m:18
function samples = performSampling(params)
Randomly generates input samples by choosing params and time parameter by chance. ...