Class method.

do_mpc.sampling.samplingplanner.SamplingPlanner.set_sampling_var(self, name, fun_var_pdf=None)

Introduce new sampling variables to the SamplingPlanner. Define variable name. Optionally add a function to generate values for the sampled variable (e.g. following some distribution). The parameter fun_var_pdf defaults to None.


If no value-generating function is passed (for any of the introduced variables), all sampling cases must be created manually with add_sampling_case().


Value generating function fun_var_pdf must not require inputs.


sp = do_mpc.sampling.SamplingPlanner()

# Plan with two variables alpha and beta:
sp.set_sampling_var('alpha', np.random.randn)
sp.set_sampling_var('beta', lambda: np.random.randint(0,5))

In the example we have passed a BuiltinFunction for the introduced variable alpha. We use the function that created values from the random normal distribution with zero mean and unity covariance. For the variable beta we created a new lambda function that draws random integers from 0 to 5.

  • name (string) – Name of the sampled variable
  • fun_var_pdf (Function of BuiltinFunction) – Declare the value-generating function of the sampled variable
  • assertionname must be string
  • assertionfun_var_pdf must be Function or BuiltinFunction

This page is auto-generated. Page source is not available on Github.