Various ways to generate datapoints from the solution space, such that it is well covered. Uses IO_Objects.Descriptor to determine which inputs are valid.

class sampling.adaptive_sampler_lv(P, P_out, n_new, problem, evaluator, reg, test_in, test_out, scaler=None, scaler_out=None, verbose=False)[source]

Represents an adaptive sampler which iteratively picks simulation samples and runs them.

sampling.add_extremes(df: pandas.core.frame.DataFrame, problem: besos.problem.Problem) → pandas.core.frame.DataFrame[source]

Adds two datapoints with the minimum and maximum values for each attribute.

  • df – existing data to which the extreme values should be added.
  • problem – the problem defining which values are valid.

df with 2 added rows, one with maximal values, one with minimal values.

sampling.dist_sampler(sampler: Callable[[int, int, Any], numpy.ndarray], problem: besos.problem.Problem, num_samples: int, *args, **kwargs) → pandas.core.frame.DataFrame[source]

uses the sampling function provided to generate num_samples sets of values These values will be valid for the corresponding inputs

  • problem – Problem that the inputs should apply to
  • sampler – a function that is used to produce the distribution of samples
  • num_samples – number of samples to take
  • args – Arguments passed to the sampling function
  • kwargs – Arguments passed to the sampling function

pandas DataFrame with one column per parameter, and num_samples rows

sampling.extremes(samples: int, attributes: int = None) → numpy.ndarray[source]

This sampler generates datapoints corresponding to the extremes of a problem.

  • samples – the number of samples. Must be equal to 2 (this argument is available in order to implement the sampler interface) If only one argument is provided, that argument will be assigned to attributes, even though samples is listed first.
  • attributes – the number of attributes for which to generate samples

An array containing 2 samples: one with all zeroes, one with all ones. When transformed by a problem, these become minimal and maximal values for that problem.


rand(d0, d1, …, dn)

Random values in a given shape.


This is a convenience function for users porting code from Matlab, and wraps random_sample. That function takes a tuple to specify the size of the output, which is consistent with other NumPy functions like numpy.zeros and numpy.ones.

Create an array of the given shape and populate it with random samples from a uniform distribution over [0, 1).

Parameters:d1, .., dn (d0,) – The dimensions of the returned array, must be non-negative. If no argument is given a single Python float is returned.
Returns:out – Random values.
Return type:ndarray, shape (d0, d1, ..., dn)

See also



>>> np.random.rand(3,2)
array([[ 0.14022471,  0.96360618],  #random
       [ 0.37601032,  0.25528411],  #random
       [ 0.49313049,  0.94909878]]) #random