Skip to content

Commit afb4a38

Browse files
committed
fix the documentation for AverageLearner1D
1 parent 44883d7 commit afb4a38

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

docs/source/tutorial/tutorial.AverageLearner1D.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,26 @@ First, we define the (noisy) function to be sampled. Note that the parameter
2828

2929
.. jupyter-execute::
3030

31-
def noisy_peak(x, sigma=0, peak_width=0.05, offset=-0.5):
31+
def noisy_peak(seed_x, sigma=0, peak_width=0.05, offset=-0.5):
32+
seed, x = seed_x # tuple with seed and `x` value
3233
y = x ** 3 - x + 3 * peak_width ** 2 / (peak_width ** 2 + (x - offset) ** 2)
33-
noise = np.random.normal(0, sigma)
34+
rng = np.random.RandomState(seed)
35+
noise = rng.normal(scale=sigma)
3436
return y + noise
3537

3638
This is how the function looks in the absence of noise:
3739

3840
.. jupyter-execute::
3941

4042
xs = np.linspace(-2, 2, 500)
41-
ys = noisy_peak(xs, sigma=0)
43+
ys = [noisy_peak((seed, xs), sigma=0) for seed, x in enumerate(xs)]
4244
hv.Path((xs, ys))
4345

4446
And an example of a single realization of the noisy function:
4547

4648
.. jupyter-execute::
4749

48-
ys = [noisy_peak(x, sigma=1) for x in xs]
50+
ys = [noisy_peak((seed, x), sigma=1) for seed, x in enumerate(xs)]
4951
hv.Path((xs, ys))
5052

5153
To obtain an estimate of the mean value of the function at each point ``x``, we

docs/source/tutorial/tutorial.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ We recommend to start with the :ref:`Tutorial `~adaptive.Learner1D``.
2121
tutorial.Learner2D
2222
tutorial.custom_loss
2323
tutorial.AverageLearner
24-
tutorial.AverageLearner1D
2524
tutorial.BalancingLearner
2625
tutorial.DataSaver
2726
tutorial.IntegratorLearner
2827
tutorial.LearnerND
28+
tutorial.AverageLearner1D
2929
tutorial.SequenceLearner
3030
tutorial.SKOptLearner
3131
tutorial.parallelism

0 commit comments

Comments
 (0)