medeq.sampler#

medeq.sampler(f)[source]#

Decorator making a user-defined function a MED sampler.

A MED sampler is simply an object defining the method .sample(n, med), where med is a complete MED instance (for e.g. using historical sampling information) and n is the number of samples between [0, 1) to return.

This decorator simply attaches a method .sample to the given function that forwards the function call to the function itself.

Examples

import medeq
import numpy as np

@medeq.sampler
def user_sampler(n, med = None):
    num_parameters = len(med.parameters)
    return np.random.random((n, num_parameters))