1 classdef Random < ParameterSampling.Interface
2 % Parameter sampling
class producing randomly distributed parameter samples
3 % in sparameter space `{\cal M}`.
5 properties(SetAccess=
private, Dependent)
11 %
string specifying the random generator to be used
16 % cell vector with min and max values
for each parameter component
19 % a random seed
for initialization of the random generator (Default =
20 % random value initialized with clock)
23 % number of parameters in the sample
26 %
boolean value determining whether a logarithmic
function shall be
27 % applied on the uniform distribution of the parameter samples.
28 log_distribution =
false;
33 function rps =
Random(nparameters, seed, log_distribution)
34 %
function rps =
Random(nparameters, seed, log_distribution)
38 % nparameters: @copydoc Random.nparameters
39 % seed: @copydoc Random.seed
40 % log_distribution: @copydoc Random.log_distribution
47 rps.seed = sum(100*clock);
50 rps.nparameters = nparameters;
54 function this = init_sample(
this, dmodel)
55 %
function init_sample(
this, dmodel)
60 % This method initializes the random number generator with the given #seed.
61 this.ranges = dmodel.mu_ranges;
62 rand(this.method, this.seed);
63 this.init_done =
true;
66 function size = size(
this)
67 %
function size = size(
this)
71 size = this.nparameters;
74 function M = get.sample(this)
77 % copied from rand_uniform() written by
78 % \author Bernard Haasdonk 29.3.2007
79 % adapted by Martin Drohmann 31.3.2011
81 assert(~isempty(this.ranges));
82 rand(this.method, this.seed);
84 mu_dim = length(this.ranges);
85 M = rand(this.nparameters, mu_dim);
87 mu_range = this.ranges{i};
88 if this.log_distribution
89 M(:,i) = exp(M(:,i)*(log(mu_range(2)-mu_range(1)))) + mu_range(1);
91 M(:,i) = M(:,i)*(mu_range(2)-mu_range(1)) + mu_range(1);