set_sample_function

Class method.

do_mpc.sampling.sampler.Sampler.set_sample_function(self, sample_function)

Set sample generating function. The sampling function produces a sample result for each sample definition in the sampling_plan and is called in the method sample_data().

It is important that the sample function only uses keyword arguments with the same name as previously defined in the sampling_plan.

Example:

sp = do_mpc.sampling.SamplingPlanner()

sp.set_sampling_var('alpha', np.random.randn)
sp.set_sampling_var('beta', lambda: np.random.randint(0,5))

sampler = do_mpc.sampling.Sampler(plan)

def sample_function(alpha, beta):
    return alpha*beta

sampler.set_sample_function(sample_function)
Parameters:sample_function (FunctionType) – Function to create each sample of the sampling plan.

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