Browse code

add short code example to the README.rst

Bas Nijholt authored on 06/08/2020 15:16:49 • GitHub committed on 06/08/2020 15:16:49
Showing 1 changed files
... ...
@@ -63,6 +63,21 @@ with built-in support for
63 63
 Examples
64 64
 --------
65 65
 
66
+Adaptively learning a 1D function (the `gif` below) and live-plotting the process in a Jupyter notebook is as easy as
67
+
68
+.. code:: python
69
+
70
+    from adaptive import notebook_extension, Runner, Learner1D
71
+    notebook_extension()
72
+
73
+    def peak(x, a=0.01):
74
+        return x + a**2 / (a**2 + x**2)
75
+
76
+    learner = Learner1D(peak, bounds=(-1, 1))
77
+    runner = Runner(learner, goal=lambda l: l.loss() < 0.01)
78
+    runner.live_info()
79
+
80
+
66 81
 .. raw:: html
67 82
 
68 83
   <img src="https://user-images.githubusercontent.com/6897215/38739170-6ac7c014-3f34-11e8-9e8f-93b3a3a3d61b.gif" width='20%'> </img> <img src="https://user-images.githubusercontent.com/6897215/35219611-ac8b2122-ff73-11e7-9332-adffab64a8ce.gif" width='40%'> </img> <img src="https://user-images.githubusercontent.com/6897215/47256441-d6d53700-d480-11e8-8224-d1cc49dbdcf5.gif" width='20%'> </img>