adaptive.AverageLearner

class adaptive.AverageLearner(*args, **kwargs)[source]

Bases: adaptive.learner.base_learner.BaseLearner

A naive implementation of adaptive computing of averages.

The learned function must depend on an integer input variable that represents the source of randomness.

Parameters
  • atol (float) – Desired absolute tolerance.

  • rtol (float) – Desired relative tolerance.

  • min_npoints (int) – Minimum number of points to sample.

data

Sampled points and values.

Type

dict

pending_points

Points that still have to be evaluated.

Type

set

npoints

Number of evaluated points.

Type

int

ask(n, tell_pending=True)[source]

Choose the next ‘n’ points to evaluate.

Parameters
  • n (int) – The number of points to choose.

  • tell_pending (bool, default: True) – If True, add the chosen points to this learner’s pending_points. Set this to False if you do not want to modify the state of the learner.

data: dict
loss(real=True, *, n=None)[source]

Return the loss for the current state of the learner.

Parameters

real (bool, default: True) – If False, return the “expected” loss, i.e. the loss including the as-yet unevaluated points (possibly by interpolation).

property mean

The average of all values in data.

property n_requested
npoints: int
pending_points: set
plot()[source]

Returns a histogram of the evaluated data.

Returns

A histogram of the evaluated data.

Return type

holoviews.element.Histogram

remove_unfinished()[source]

Remove uncomputed data from the learner.

property std

The corrected sample standard deviation of the values in data.

tell(n, value)[source]

Tell the learner about a single value.

Parameters
  • x (A value from the function domain) –

  • y (A value from the function image) –

tell_pending(n)[source]

Tell the learner that ‘x’ has been requested such that it’s not suggested again.