Browse code

remove _inline_js=False in adaptive.notebook_extension call

Bas Nijholt authored on 17/09/2020 22:19:56
Showing 1 changed files
... ...
@@ -14,7 +14,7 @@ Tutorial `~adaptive.AverageLearner`
14 14
     :hide-code:
15 15
 
16 16
     import adaptive
17
-    adaptive.notebook_extension(_inline_js=False)
17
+    adaptive.notebook_extension()
18 18
 
19 19
 The next type of learner averages a function until the uncertainty in
20 20
 the average meets some condition.
Browse code

remove thebelab buttons

Bas Nijholt authored on 01/08/2019 16:10:21
Showing 1 changed files
... ...
@@ -10,8 +10,6 @@ Tutorial `~adaptive.AverageLearner`
10 10
     The complete source code of this tutorial can be found in
11 11
     :jupyter-download:notebook:`tutorial.AverageLearner`
12 12
 
13
-.. thebe-button:: Run the code live inside the documentation!
14
-
15 13
 .. jupyter-execute::
16 14
     :hide-code:
17 15
 
Browse code

add thebelab activation buttons

Bas Nijholt authored on 10/07/2019 19:30:06
Showing 1 changed files
... ...
@@ -10,6 +10,8 @@ Tutorial `~adaptive.AverageLearner`
10 10
     The complete source code of this tutorial can be found in
11 11
     :jupyter-download:notebook:`tutorial.AverageLearner`
12 12
 
13
+.. thebe-button:: Run the code live inside the documentation!
14
+
13 15
 .. jupyter-execute::
14 16
     :hide-code:
15 17
 
Browse code

do not inline the HoloViews JS

Bas Nijholt authored on 26/03/2019 12:44:31
Showing 1 changed files
... ...
@@ -14,7 +14,7 @@ Tutorial `~adaptive.AverageLearner`
14 14
     :hide-code:
15 15
 
16 16
     import adaptive
17
-    adaptive.notebook_extension()
17
+    adaptive.notebook_extension(_inline_js=False)
18 18
 
19 19
 The next type of learner averages a function until the uncertainty in
20 20
 the average meets some condition.
Browse code

fix the incorrect loss requirement for the AverageLearner in the docs

Bas Nijholt authored on 21/10/2018 14:28:17
Showing 1 changed files
... ...
@@ -40,7 +40,8 @@ implementation the seed parameter can be ignored by the function).
40 40
 .. jupyter-execute::
41 41
 
42 42
     learner = adaptive.AverageLearner(g, atol=None, rtol=0.01)
43
-    runner = adaptive.Runner(learner, goal=lambda l: l.loss() < 2)
43
+    # `loss < 1` means that we reached the `rtol` or `atol`
44
+    runner = adaptive.Runner(learner, goal=lambda l: l.loss() < 1)
44 45
 
45 46
 .. jupyter-execute::
46 47
     :hide-code:
Browse code

change "execute" into "jupyter-execute"

Bas Nijholt authored on 18/10/2018 18:21:31
Showing 1 changed files
... ...
@@ -8,11 +8,10 @@ Tutorial `~adaptive.AverageLearner`
8 8
 
9 9
 .. seealso::
10 10
     The complete source code of this tutorial can be found in
11
-    :jupyter-download:notebook:`AverageLearner`
11
+    :jupyter-download:notebook:`tutorial.AverageLearner`
12 12
 
13
-.. execute::
13
+.. jupyter-execute::
14 14
     :hide-code:
15
-    :new-notebook: AverageLearner
16 15
 
17 16
     import adaptive
18 17
     adaptive.notebook_extension()
... ...
@@ -25,7 +24,7 @@ the learner must formally take a single parameter, which should be used
25 24
 like a “seed” for the (pseudo-) random variable (although in the current
26 25
 implementation the seed parameter can be ignored by the function).
27 26
 
28
-.. execute::
27
+.. jupyter-execute::
29 28
 
30 29
     def g(n):
31 30
         import random
... ...
@@ -38,20 +37,20 @@ implementation the seed parameter can be ignored by the function).
38 37
         random.setstate(state)
39 38
         return val
40 39
 
41
-.. execute::
40
+.. jupyter-execute::
42 41
 
43 42
     learner = adaptive.AverageLearner(g, atol=None, rtol=0.01)
44 43
     runner = adaptive.Runner(learner, goal=lambda l: l.loss() < 2)
45 44
 
46
-.. execute::
45
+.. jupyter-execute::
47 46
     :hide-code:
48 47
 
49 48
     await runner.task  # This is not needed in a notebook environment!
50 49
 
51
-.. execute::
50
+.. jupyter-execute::
52 51
 
53 52
     runner.live_info()
54 53
 
55
-.. execute::
54
+.. jupyter-execute::
56 55
 
57 56
     runner.live_plot(update_interval=0.1)
Browse code

add tutorials

Bas Nijholt authored on 17/10/2018 13:30:10
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,57 @@
1
+Tutorial `~adaptive.AverageLearner`
2
+-----------------------------------
3
+
4
+.. note::
5
+   Because this documentation consists of static html, the ``live_plot``
6
+   and ``live_info`` widget is not live. Download the notebook
7
+   in order to see the real behaviour.
8
+
9
+.. seealso::
10
+    The complete source code of this tutorial can be found in
11
+    :jupyter-download:notebook:`AverageLearner`
12
+
13
+.. execute::
14
+    :hide-code:
15
+    :new-notebook: AverageLearner
16
+
17
+    import adaptive
18
+    adaptive.notebook_extension()
19
+
20
+The next type of learner averages a function until the uncertainty in
21
+the average meets some condition.
22
+
23
+This is useful for sampling a random variable. The function passed to
24
+the learner must formally take a single parameter, which should be used
25
+like a “seed” for the (pseudo-) random variable (although in the current
26
+implementation the seed parameter can be ignored by the function).
27
+
28
+.. execute::
29
+
30
+    def g(n):
31
+        import random
32
+        from time import sleep
33
+        sleep(random.random() / 1000)
34
+        # Properly save and restore the RNG state
35
+        state = random.getstate()
36
+        random.seed(n)
37
+        val = random.gauss(0.5, 1)
38
+        random.setstate(state)
39
+        return val
40
+
41
+.. execute::
42
+
43
+    learner = adaptive.AverageLearner(g, atol=None, rtol=0.01)
44
+    runner = adaptive.Runner(learner, goal=lambda l: l.loss() < 2)
45
+
46
+.. execute::
47
+    :hide-code:
48
+
49
+    await runner.task  # This is not needed in a notebook environment!
50
+
51
+.. execute::
52
+
53
+    runner.live_info()
54
+
55
+.. execute::
56
+
57
+    runner.live_plot(update_interval=0.1)