Module: FeldtRuby::Statistics::DesignOfExperiments

Included in:
RCommunicator
Defined in:
lib/feldtruby/statistics/design_of_experiments.rb

Overview

Functions for designing parameter exploration experiments using Bayesian Treed Gaussian Process models.

Parameters are assumed to be given in a hash, mapping a parameter name to its range of allowed values, like:

IndependenVars = {
  :PopulationSize => [5, 500],
  :PopulationSamplerRadius => [4, 500], # must actually be smaller than the population size or it makes no difference, how to spec such constraints?
  :F => [0.0, 1.0],
  :CR => [0.0, 1.0],
  :numEvals => [1e3, 1e5] # Or should we vary this for each setting of the others and just measure the outputs at several points of numEvals?
}

DependentVars = {
  Y1 = # execution_time for running the algorithm
  Y2 = # best model RMS error
}

Instance Method Summary collapse

Instance Method Details

#latin_hypercube_sample_of_parameters(parameters, numSamples) ⇒ Object

Do a latin hypercube sampling of the parameter space with bouding box per parameter specified in parameters.



24
25
26
27
28
29
30
31
32
33
# File 'lib/feldtruby/statistics/design_of_experiments.rb', line 24

def latin_hypercube_sample_of_parameters(parameters, numSamples)
  include_library("tgp")
  param_order = parameters.keys.sort
  script = <<-EOS
    params <- #{parameters_to_R_data_frame(parameters, param_order)};
    x_candidates <- lhs(#{numSamples}, params);
  EOS
  subst_eval script, {}
  pull_matrix_variable_to_hash_with_column_names "x_candidates", param_order
end

#parameters_to_R_data_frame(parameters, param_order = parameter.keys) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/feldtruby/statistics/design_of_experiments.rb', line 35

def parameters_to_R_data_frame(parameters, param_order = parameter.keys)
  s = param_order.map do |p|
    lim = parameters[p]
    "c(#{lim[0]}, #{lim[1]})"
  end.join(", ")
  "rbind(#{s})"
end